PDA

View Full Version : QListWidget in ListMode - still has icon space



high_flyer
29th March 2007, 22:40
Hi,
a short question:
From the docs I understood, that if I set the view mode to ListMode, then the list will show the items with out an icon.
I constructed a simple list with strings, but all strings have a space between them and the left border of the widget - I presume its where the icon should be - it looks like the IconMode just there is space istead of an icon.
A hint in the right direction will be most appreciated.
Thanks.

high_flyer
30th March 2007, 11:19
hmm... no one knows?:confused:

jpn
30th March 2007, 11:27
Sorry, I'm not sure if I understood the problem description correctly. At least I have no extra spacing for icon there.. Could you provide a screenshot? :)

high_flyer
30th March 2007, 12:01
Thanks for replying.
I can't provide a screen shot at the moment, only later this evening (not at home)...
So, basically, if I use ListMode, and popluate it with strings, then I should get a regular list, so:
|item1 |
|item2 |
|item3 |

And not what I am getting - so:
| item1 |
| item2 |
| item3 |

Right?
Then I must be doing somthing wrong, I'll look it up again this evening.

Daedalus
30th March 2007, 17:16
As far as I understand the documentation, the QListWidget is coded to operate in IconMode mode and has space for it reserved. A Widget derived from QListView and set to ListMode should behave like you expected it.

high_flyer
30th March 2007, 18:13
A Widget derived from QListView and set to ListMode should behave like you expected it.
Thanks for the input.
But I don't understand how deriving and not changing the way the widget draws will help.

Ok, here is my code, and the screen shot:


uiLarge.listPort->setViewMode(QListView::ListMode);
QListWidgetItem *temp = new QListWidgetItem("ttyS0");
temp->setSizeHint(QSize(uiLarge.listPort->width(),40)); //just experimenting, this works as you can see in the image
uiLarge.listPort->addItem(temp);
new QListWidgetItem("ttyS1",uiLarge.listPort);
new QListWidgetItem("ttyS2",uiLarge.listPort);
new QListWidgetItem("ttyS3",uiLarge.listPort);
new QListWidgetItem("ttyS4",uiLarge.listPort);

jpn
30th March 2007, 18:58
Which style is that? Have you tried with other styles?

high_flyer
30th March 2007, 19:06
Which style is that?
The default, system style, in this case plastik...
No I didn't try other styles I don't need to...
Should I?
I mean, this should be the most simple thing - just having a list of strings...
I don't think this has to do with styles..
The green background is just a background pixmap on the dialog.
@Jpn: you said that you list is not like that - could you show me your code?
My guess is that I am doing (or not doing) something very basic, but I don't know what..
Is there any thing I should note when dealing with QListWidget?
I am really new to data aware views in Qt4 (as one can tell).
Thanks

jpn
30th March 2007, 19:16
This is my minimalistic test case:


#include <QtGui>

int main(int argc, char* argv[])
{
QApplication a(argc, argv);
QListWidget list;
list.setViewMode(QListView::ListMode);
for (int i = 0; i < 5; ++i)
list.addItem(QString("ttyS%1").arg(i));
list.show();
return a.exec();
}

The attached screenshot taken with Qt 4.2.3 / X11 and QPlastiqueStyle.

high_flyer
30th March 2007, 19:35
Thanks.
I tried you code, thinking maybe the item initializtion played a part in it, but it stays exatly the same... hmm....:confused:


uiLarge.listPort->setViewMode(QListView::ListMode);
uiLarge.listPort->addItem(QString("ttyS0"));
uiLarge.listPort->addItem(QString("ttyS1"));
uiLarge.listPort->addItem(QString("ttyS2"));
uiLarge.listPort->addItem(QString("ttyS3"));
uiLarge.listPort->addItem(QString("ttyS4"));

It looks EXACTLY the same as before for me...
I hate such situations...

Thanks though!

The only difference is that my list is initializes in an ui faile...
Is there an propery in designer that might change this?

high_flyer
30th March 2007, 19:43
found it -
designer gives defalut spacing of 20.

Thanks for your help!