Page 2 of 2 FirstFirst 12
Results 21 to 22 of 22

Thread: custom painting in QListWidget

  1. #21
    Join Date
    Mar 2007
    Posts
    13
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: custom painting in QListWidget

    I didnt look at QItemDelegate to see what can be overriden.
    Thanks alot !

    I still need to know the width of the vertical scrollbar.
    I'll try to explain why.
    I want QListWidget to display only 4 items at once (icons with text underneath)
    (so the client rect is splitted in 4 equal parts).

    For this i set IconMode view mode.
    In order to display only 4 items I need to compute an item size and call QListWidgetItem::setHintSize( )
    The item width cannot be just QListWidget::contentsRect().Width( ) / 2 because I need to take into account the left vertical scrollbar width also. Otherwise a horizontal scrollbar will appear.

    that's why I need the width of the vertical scrollbar.

    After I inserted items I tried to call
    QRect rc = ui.listWidget->verticalScrollBar()->rect();
    but it does not give consistent results.
    I observed that the right size is computed after the first display.
    is there a way to get scrollbar metrics \ force internal computation before actual painting ?
    Last edited by Andrew; 30th March 2007 at 13:27.

  2. #22
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: custom painting in QListWidget

    Qt Code:
    1. int width = style()->pixelMetric(QStyle::PM_ScrollBarExtent);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. custom widgets painting image formats
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 12th March 2007, 10:33
  2. Replies: 1
    Last Post: 5th March 2007, 20:50
  3. Replies: 13
    Last Post: 15th December 2006, 11:52
  4. keypress while editing an item in QListWidget
    By Beluvius in forum Qt Programming
    Replies: 3
    Last Post: 4th April 2006, 09:56
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.