PDA

View Full Version : I need a widget that can display lists of column-aligned strings



hamstap85
29th June 2016, 19:20
Hello! I'm trying to display a list of items, each item represented by 3 strings. I was thinking of going with a QListWidget and tab separating the strings for alignment, but they're not all nominal length and I ended up with some offset strings. I noticed QTableView/QTableWidget and thought about using that, but I don't like the table lines separating the items.

Also, about the QTable things, what is the difference between QTableView and QTableWidget? Why would you use one over the other? Is one inherited from the other and only one should be used in user code while the other one is used internally or something? It's not obvious from the names of the classes, and even more confusing when trying to read through the docs on http://doc.qt.io/qt-5/qtableview.html and http://doc.qt.io/qt-5/qtablewidget.html how they should be used.

I hope that's enough to start with. Please do ask for clarification if I left anything out. If it helps, I'm running PyQt5.

ChrisW67
29th June 2016, 21:28
QTableView::setShowGrid()

QTableView is a generic table widget that displays data from a user-supplied QAbstractItemModel. QTableWidget is convenience subclass of QTableView that has an internal data model and a public API for manipulating items in that model. Which you use depends on your program data source and design.

Look for "Model/View Programming" in the Qt docs.

hamstap85
30th June 2016, 05:51
Oh, this is so helpful!! Thanks so much!