Results 1 to 14 of 14

Thread: How to make QListView consume the space when rows decrease in height on h-resize?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2014
    Posts
    10
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to make QListView consume the space when rows decrease in height on h-resize?

    A single QTextDocument is probably not an option, since I suspect all the HTML /CSS parsing to be quite slow. I didn't measure anyhing yet, though. Still busy with other stuff. Richtext is not my friend. ^^
    Have a happy new year

  2. #2
    Join Date
    Dec 2014
    Posts
    10
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to make QListView consume the space when rows decrease in height on h-resize?

    Since I had the same problem (rows' heights) with a QTreeView now, I did some digging through Qt's source code.
    Look what I've found:
    Qt Code:
    1. .../qtbase/src/widgets/itemviews$ grep -n sizeHintChanged *
    2. qabstractitemdelegate.cpp:163: \fn void QAbstractItemDelegate::sizeHintChanged(const QModelIndex &index)
    3. qabstractitemdelegate.h:120: void sizeHintChanged(const QModelIndex &);
    4. qabstractitemview.cpp:834: disconnect(d->itemDelegate, SIGNAL(sizeHintChanged(QModelIndex)), this, SLOT(doItemsLayout()));
    5. qabstractitemview.cpp:843: connect(delegate, SIGNAL(sizeHintChanged(QModelIndex)), this, SLOT(doItemsLayout()), Qt::QueuedConnection);
    To copy to clipboard, switch view to plain text mode 
    That's all. See how the QModelIndex that is passed to sizeHintChanged is ignored? Any sizeHintChanged signal just triggers a relayout.
    Even more interesting is the doItemsLayout() slot. It is public and available in all of Qt's item view widgets, but it is not documented. That's exactly what I was looking for
    Someone asked if he could rely on that on another forum a few years ago. So I'm going to repeat the question here.

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

    Default Re: How to make QListView consume the space when rows decrease in height on h-resize?

    If it is undocumented and not a virtual method then you cannot expect the method to work in future Qt releases. Of course it is unlikely that it goes away until Qt 6.0.
    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.


  4. #4
    Join Date
    Dec 2014
    Posts
    10
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to make QListView consume the space when rows decrease in height on h-resize?

    It's virtual. From qabstractitemview.h:
    Qt Code:
    1. public Q_SLOTS:
    2. virtual void reset();
    3. virtual void setRootIndex(const QModelIndex &index);
    4. virtual void doItemsLayout();
    5. virtual void selectAll();
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. How to add space b/w column and rows of gridlayout.
    By Niamita in forum Qt Programming
    Replies: 3
    Last Post: 8th July 2011, 08:55
  2. QCalendarWidget - height rows
    By pease in forum Qt Programming
    Replies: 1
    Last Post: 15th April 2010, 18:31
  3. How to set rows of QtableWidget to the same height?
    By sawerset in forum Qt Programming
    Replies: 3
    Last Post: 7th December 2008, 19:09
  4. Height of the text without balnk space at the top
    By THRESHE in forum Qt Programming
    Replies: 6
    Last Post: 19th March 2008, 14:33
  5. Replies: 2
    Last Post: 22nd January 2008, 17:10

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
  •  
Qt is a trademark of The Qt Company.