Print a selected item from a table to a lineEdit

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Post Reply
Amal
Posts: 40
Joined: Sat Jul 04, 2020 9:48 am

Print a selected item from a table to a lineEdit

Post by Amal »

Good morning,
Working on graphic user interfaces I try to add the European norms tolerance table and the fit property. But I can't print the table Item in the tolerance line-edit. Anyone has an idea I will be thankful. :D Image
User avatar
M4x
Veteran
Posts: 1483
Joined: Sat Mar 11, 2017 9:23 am
Location: Germany

Re: Print a selected item from a table to a lineEdit

Post by M4x »

Does this overlap with the information included in the PartDesign hole feature? If that's the case, I think (at the moment) the information used there is hardcoded. It got improved / corrected / completed a while ago. Please have a look: https://forum.freecadweb.org/viewtopic.php?f=19&t=51491
Amal
Posts: 40
Joined: Sat Jul 04, 2020 9:48 am

Re: Print a selected item from a table to a lineEdit

Post by Amal »

I need just to add a property to an object in the property table. The value in the table, I need to print it in the line edit just all.
I need a connection between the selected item and the line edit but I don't know how it will be done. :roll:
TheMarkster
Veteran
Posts: 5513
Joined: Thu Apr 05, 2018 1:53 am

Re: Print a selected item from a table to a lineEdit

Post by TheMarkster »

If you want to add a new property to an object, right click in the property view and select "show all". Right click again for a new context menu with add property one of the options.
Snip macro screenshot-4eac19.png
Snip macro screenshot-4eac19.png (9.8 KiB) Viewed 1237 times
User avatar
ebrahim raeyat
Posts: 621
Joined: Sun Sep 09, 2018 7:00 pm
Location: Iran
Contact:

Re: Print a selected item from a table to a lineEdit

Post by ebrahim raeyat »

what is your table? it is QTableView? then you can use this signal:

Code: Select all

tableview.clicked.connect(func)

def func(index):
   row = index.row()
   column = index.column()
   DO MORE
is this your answer?
Amal
Posts: 40
Joined: Sat Jul 04, 2020 9:48 am

Re: Print a selected item from a table to a lineEdit

Post by Amal »

ebrahim raeyat wrote: Sun Aug 01, 2021 2:12 am what is your table?
it is a tableWidget.

Code: Select all

        self.tableWidget = QtWidgets.QTableWidget(self.centralwidget)
        self.tableWidget.setGeometry(QtCore.QRect(650, 20,700, 750))
        self.tableWidget.setRowCount(113)
        self.tableWidget.setColumnCount(14)
        self.tableWidget.setObjectName("tableWidget")
        item = QtWidgets.QTableWidgetItem()
        self.tableWidget.setItem(0, 0, item)
        item = QtWidgets.QTableWidgetItem()
        self.tableWidget.setItem(0, 1, item)
        ......
        
                self.tableWidget.selectionModel().selectionChanged.connect(self.on_selectionChanged) #connection
        self.tableWidget.itemClicked['QTableWidgetItem*'].connect(self.lineEdit.paste)
I use functions

Code: Select all

    def on_itemClicked():
        for ix in selected.indexes():
            for i in range(113):
               for j in range(14):
                   item = self.tableWidget.item()
        print(ix.tableWidget.item(""))
        print(item)


    def on_selectionChanged (self, selected):     
        for ix in selected.indexes():
            print ('Selected Cell Location : {0}, {1}'. format(ix.row() , ix.column()))
The "on_itemClicked" have no effect
And the "on_selectionChanged" print just the cell location and I want to print the cell content.
User avatar
ebrahim raeyat
Posts: 621
Joined: Sun Sep 09, 2018 7:00 pm
Location: Iran
Contact:

Re: Print a selected item from a table to a lineEdit

Post by ebrahim raeyat »

Amal wrote: Tue Aug 10, 2021 9:48 pm
ebrahim raeyat wrote: Sun Aug 01, 2021 2:12 am what is your table?
it is a tableWidget.

Code: Select all

    def on_itemClicked(): 
I think the problem is that you did not pass any argument to on_itemClicked method:

Code: Select all

def on_itemClicked(self, selected):
Post Reply