PDA

View Full Version : How to port QListBox and QListBoxItem in Qtopia 2.2.0 to 4.2.0



mellibra
22nd October 2007, 16:28
Hi guys,

Have someone tried this?

wysota
22nd October 2007, 19:18
What's there to try? QListBox equivalent in Qt4 is QListWidget. The API doesn't differ that much, so it should be easy for you to port it.

mellibra
23rd October 2007, 02:34
The problem here is with QListBoxItem. In 2.2.0, I use my own class inherits from QListBoxItem, and I re-implement its paint. So what's QListBoxItem in 4.4.0?

wysota
23rd October 2007, 09:13
QListWidgetItem. Please at least take a look at QListWidget docs before asking such questions...

mellibra
24th October 2007, 04:22
I don't think you got my question or because of my poor English.

If you inherits QListBoxItem, unless you re-implement paint(), you will always get a compilation error. And by using paint(), you could custom the item's view.

Have a look at call history application in Qtopia 2.2.0. For each item, it has two rows to display in different fonts. Show me, how you implement this using QListWidgetItem in Qtopia 4.2.0

wysota
24th October 2007, 09:04
The looks of items in Qt4 are controled by an entity called the delegate. If you want to customize how an item gets rendered, you need to subclass QItemDelegate or QAbstractItemDelegate. But if you only need simple customization, it is possible you can do it without a custom delegate. So the basic question is - how do you want your item to look like? I suggest you read the docs about model-view programming: http://doc.trolltech.com/latest/model-view-programming.html