Results 1 to 2 of 2

Thread: updateEditorGeometry() and height change

  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default updateEditorGeometry() and height change

    Hi,

    in a sublassed QItemDelegate I create an editor which is higher than the normal item height (tested with QListWidget and QTreeVeiw). Therefore I also reimplement updateEditorGeometry() which updates the editor geometry to the adjusted size of my widget. But the problem is, that the other items don't moved down. So the editor hides the items below. How to move the positions of the other items?

    Lykurg

    Qt Code:
    1. myDelegate::myDelegate( QObject *_parent ) :
    2. QItemDelegate( _parent )
    3. {
    4. tw = (QListWidget*) _parent;
    5. }
    6.  
    7. myDelegate::~myDelegate()
    8. {
    9. }
    10.  
    11. QWidget * myDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &, const QModelIndex & ) const
    12. {
    13. editorWidget *ed = new editorWidget( parent );
    14. ed->adjustSize();
    15. return ed;
    16. }
    17.  
    18. void myDelegate::updateEditorGeometry( QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &/*index*/) const
    19. {
    20. QRect r = option.rect;
    21. r.setX( 30 ); // just for showing the overlay
    22. r.setSize( editor->sizeHint() );
    23. editor->setGeometry( r );
    24. }
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images

  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: updateEditorGeometry() and height change

    Well... a short answer is you can't. A bit longer is to try to update the size hint of the item and emit a proper signal from the delegate.

    An alternative is to make the editor a popup widget, like a combobox or QDateEdit.

Similar Threads

  1. Set height of QTableView to fit exact number of rows.
    By Ben.Hines in forum Qt Programming
    Replies: 3
    Last Post: 17th January 2019, 01:49
  2. QTextEdit preferred height
    By darksaga in forum Qt Programming
    Replies: 1
    Last Post: 23rd May 2007, 02:03
  3. How can I get the Systray height ?
    By Nyphel in forum Qt Programming
    Replies: 3
    Last Post: 12th March 2007, 09:04
  4. height()
    By mickey in forum Newbie
    Replies: 1
    Last Post: 22nd March 2006, 20:32
  5. how change the QListBox item position by pixel
    By roy_skyx in forum Qt Programming
    Replies: 2
    Last Post: 20th January 2006, 01:34

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.