Skip navigation.
KDE Developer's Journals

Qt4 ItemViews

icefox's picture
Read some docs
87% (337 votes)
Used QTreeWidget, QListWidget, or QTableWidget
4% (17 votes)
Used QStandardItemModel and a view
1% (4 votes)
Wrote my own model or delegate
6% (22 votes)
Wrote my own view
1% (4 votes)
Wrote parts of it or submitted a patch
1% (3 votes)
Total votes: 387

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
rich's picture

What I'd like...

What I'd like is for the wrapper classes to be less shit. Eg. You can insert a string at a specific position of a QListWidget using insert( int, QString ) but there's no way to get it out again without doing a dance with QListWidgetItem. With tree views it's worse.

icefox's picture

Specifics please

From looking at the docs I would think you should be able to do:

listWidget->insertItem(10, "foo");
delete listWidget->takeItem(10);

Are you thinking of something else?

rich's picture

Yeah I'm thinking of

Yeah I'm thinking of something else. I'd like to be able to go:

listWidget->insertItem(10, QString("Foo") );

Then later:

QString s = listWidget->itemText( 10 );

I'd also like a set of corresponding signals as we had in Qt 3.x.

icefox's picture

like this:

listWidget->insertItem(10, QString("Foo") );
QString s = listWidget->item(10)->text();

Many of the signals such as the selectionChanged() are now in the QItemSelectionModel

rich's picture

No, not like that

The trouble with that is that you have to search through the docs for the model-view classes - exactly what the wrapper is supposed to avoid. The wrapper should be usable on its own IMHO, and currently it is not. There's also the issue of the non-orthoganal API - you can set the text directly but not get it back.

icefox's picture

wrapping signals

The convenience widgets do wrap the signals so you can just connect to them if you want to.

http://doc.trolltech.com/4.2/qlistwidget.html#currentItemChanged

The current API isn't about setting text, but about inserting items with a preset text, it is orthogonal in that it then has functions to retrieve those items. Perhaps it should have a setText(int row, const &QString) and QString text(int row).

rich's picture

Yeah, I'd like to have

Yeah, I'd like to have those. It's still missing itemActivated(QString text), currentItemChanged(QString text) etc. though which we had in QListBox.

zander's picture

Missing a QListView equivalent

QTree is too complex (API wise) and it still is impossible to alter the header to look like the qlistview headers which were not whole width. (probably a bug).

All 3 view classes seem overdesigned compared to other toolkits, though.

icefox's picture

ListView headers?

I am not sure what you mean, the ListView doesn't have any headers.

zander's picture

yap

* start Qt3 Designer
* insert a "List View" (Tools->Views->ListView)
* see the "Column 1" thing at the top. Thats what I call a header.

And notice how it is not full width. This seems to be impossible to do with Qt4.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.