I need some advise about how to read PyQt’s documentation. Because on my own I can hardly figure anything out. I’m a programming newbie so sorry if my question is confusing. I’ll try to explain the best I can 🙂
This is an example of where I got stuck. I was experimenting around with QListView. Basically just trying to print out data of what I have selected in the view. I got stuck until Justin, a very patient Python tutor, showed me this bit of code.
listView.clicked.connect(B)
def B(index):
record = sqlmodel.record(index.row())
It connects a clicked signal from QListView to function B. I was very surprised that right away the clicked event sends index to B by itself. I tried to look through QListView’s documentation but can’t find anything that explains this.
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qlistview.html
In this case, where in the docs should I look at to learn about this clicked event, and the index it sends out?
Would really appreciate any advise. 🙂
Unfortunately
PyQtdocumentation is not full. Better source for knowledge is Qt documentation.In your case
QTableViewinheritsQAbstractItemView, and there is noclickedsignal inQTableViewdocs, you can find it in List of all members, including inherited members page. And you can see, that this signal comes fromQAbstractItemViewand it’s defined as:Here you can see type of function arguments (clickable).
So,
indexpassed to you function will be instance ofQModelIndexand it hasrowmethod.If you are confused with C++ syntax, another option is to use
PySidedocumentation, which is more Python friendly.QAbstractItemView.clicked in PySide docs