Question

I was wondering of any function that can ease/solve above challenge. Basically, when a GUI (containing list and table widgets) starts. Whenever user click on each item in the list, the table should also responds to data corresponding to the list item. Refer to the following example for better understanding.

From time to time, the data in list or table can be removed, modified or added by user. I would also like to implement function to gather those. Currently, I am thinking of playing around python list and dict.

Was it helpful?

Solution

You can

  • use the QListWidget.itemClicked signal.
  • Connect it to a function, that takes an QListWidgetItem as argument.
  • Identify the item and act accordingly

Example

    ...
    self.myListWidget.itemClicked.connect(self.showDataInTable)
    ....

def showDataInTable(item):
    item_name = str(item.text()) # getting item name as python string

    ... # show data or do what ever you like
    dataToShow = myDataDict[item_name]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top