Results 1 to 5 of 5

Thread: QListView + row height

  1. #1
    Join Date
    Apr 2008
    Posts
    196
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    1

    Default QListView + row height

    Hey @all,

    how can I set the row height in a QListView?
    With a QTableView i can use setRowHeight() but how i can do it with a QListView?

    LG NoRulez

  2. #2
    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: QListView + row height

    Either set the size using the SizeHintRole of the model or provide your own item delegate with reimplemented sizeHint().

  3. #3
    Join Date
    Jan 2011
    Location
    Sri Lanaka
    Posts
    64
    Thanks
    39
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: QListView + row height

    Can i set rowsize using Stylesheet of QListWidget??

  4. #4
    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: QListView + row height

    Use the ::item sub-control for QListWidget.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. The following user says thank you to wysota for this useful post:

    deepal_de (4th May 2011)

  6. #5
    Join Date
    Jan 2012
    Location
    St. Petersburg, Russia
    Posts
    14
    Thanks
    3
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    1

    Default Re: QListView + row height

    Thanks wysota, but it doesn't work for me when I'm trying to customize row height for combo box popup.
    Actually stylesheet reference recommends to do it via "QComboBox QAbstractItemView" selector, but
    "QComboBox QAbstractItemView::item" doesn't custom anything.

    I suggested that ::item subcontrol is available only for concrete QAbstractItemView subclasses, not for
    QAbstractItemView itself. I read qt code and found that QComboBox uses QComboBoxListView class which
    is a subclass of QListView. So I tried to use "QComboBox QListView::item", but it doesn't work too.

    I solved my problem with a help of this class:

    Qt Code:
    1. class CComboBoxPopupItemDelegate : public QStyledItemDelegate
    2. {
    3. public:
    4. CComboBoxPopupItemDelegate(QObject* parent = 0)
    5. : QStyledItemDelegate(parent)
    6. {
    7. }
    8.  
    9. QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const
    10. {
    11. return QSize(60, 100); //enter your values here
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 

    In client code:

    Qt Code:
    1. QAbstractItemView* view = comboBox->view();
    2. view->setItemDelegate(new CComboBoxPopupItemDelegate(this))
    To copy to clipboard, switch view to plain text mode 

    Alas I coudn't find easier solution.
    Last edited by monst; 12th May 2012 at 08:53.

Similar Threads

  1. How to Modify QListView item height?
    By blackfox in forum Qt Programming
    Replies: 7
    Last Post: 16th May 2012, 11:38
  2. Same height for QComboBox and QPushButton
    By cevou in forum Qt Programming
    Replies: 5
    Last Post: 12th May 2012, 07:56
  3. QListView word wrap
    By serega in forum Qt Programming
    Replies: 17
    Last Post: 30th August 2007, 03:13
  4. How can I get the Systray height ?
    By Nyphel in forum Qt Programming
    Replies: 3
    Last Post: 12th March 2007, 09:04
  5. height()
    By mickey in forum Newbie
    Replies: 1
    Last Post: 22nd March 2006, 20:32

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.