Results 1 to 11 of 11

Thread: QListWidget in ListMode - still has icon space

  1. #1
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QListWidget in ListMode - still has icon space

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QListWidget in ListMode - still has icon space

    hmm... no one knows?

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QListWidget in ListMode - still has icon space

    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?
    J-P Nurmi

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QListWidget in ListMode - still has icon space

    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.

  5. #5
    Join Date
    Mar 2007
    Location
    Bielefeld, Germany
    Posts
    9
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QListWidget in ListMode - still has icon space

    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.
    Last edited by Daedalus; 30th March 2007 at 17:21.

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QListWidget in ListMode - still has icon space

    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:
    Qt Code:
    1. uiLarge.listPort->setViewMode(QListView::ListMode);
    2. QListWidgetItem *temp = new QListWidgetItem("ttyS0");
    3. temp->setSizeHint(QSize(uiLarge.listPort->width(),40)); //just experimenting, this works as you can see in the image
    4. uiLarge.listPort->addItem(temp);
    5. new QListWidgetItem("ttyS1",uiLarge.listPort);
    6. new QListWidgetItem("ttyS2",uiLarge.listPort);
    7. new QListWidgetItem("ttyS3",uiLarge.listPort);
    8. new QListWidgetItem("ttyS4",uiLarge.listPort);
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images

  7. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QListWidget in ListMode - still has icon space

    Which style is that? Have you tried with other styles?
    J-P Nurmi

  8. #8
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QListWidget in ListMode - still has icon space

    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

  9. #9
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QListWidget in ListMode - still has icon space

    This is my minimalistic test case:
    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char* argv[])
    4. {
    5. QApplication a(argc, argv);
    6. list.setViewMode(QListView::ListMode);
    7. for (int i = 0; i < 5; ++i)
    8. list.addItem(QString("ttyS%1").arg(i));
    9. list.show();
    10. return a.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 
    The attached screenshot taken with Qt 4.2.3 / X11 and QPlastiqueStyle.
    Attached Images Attached Images
    J-P Nurmi

  10. #10
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QListWidget in ListMode - still has icon space

    Thanks.
    I tried you code, thinking maybe the item initializtion played a part in it, but it stays exatly the same... hmm....
    Qt Code:
    1. uiLarge.listPort->setViewMode(QListView::ListMode);
    2. uiLarge.listPort->addItem(QString("ttyS0"));
    3. uiLarge.listPort->addItem(QString("ttyS1"));
    4. uiLarge.listPort->addItem(QString("ttyS2"));
    5. uiLarge.listPort->addItem(QString("ttyS3"));
    6. uiLarge.listPort->addItem(QString("ttyS4"));
    To copy to clipboard, switch view to plain text mode 
    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?

  11. #11
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QListWidget in ListMode - still has icon space

    found it -
    designer gives defalut spacing of 20.

    Thanks for your help!

Similar Threads

  1. Replies: 13
    Last Post: 15th December 2006, 11:52
  2. linking user space and kernel space programs with qmake
    By zielchri in forum Qt Programming
    Replies: 9
    Last Post: 8th March 2006, 23:11

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.