문제

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.

도움이 되었습니까?

해결책

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]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top