Results 1 to 5 of 5

Thread: How to make headers fixed sized? (QTableWidget)

  1. #1
    Join Date
    Apr 2007
    Location
    Toruń, POLAND
    Posts
    24
    Thanks
    7
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default How to make headers fixed sized? (QTableWidget)

    Hello,

    I would like to make vertical headers fixed size -- i.e. so the user could not just drag the small separation line between cells in headers to make rows bigger or smaller.

    I though that resize mode for headers will do the trick however, after comparison:
    Qt Code:
    1. verticalHeader()->setResizeMode(QHeaderView::Fixed);
    2. horizontalHeader()->setResizeMode(QHeaderView::Interactive);
    To copy to clipboard, switch view to plain text mode 

    I see absolutely no difference in behaviour -- I mean, both are interactively resizeable.

    Thank in advance for your help.

    have a nice day, bye

  2. #2
    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: How to make headers fixed sized? (QTableWidget)

    Quote Originally Posted by macias View Post
    I though that resize mode for headers will do the trick however, after comparison:
    Qt Code:
    1. verticalHeader()->setResizeMode(QHeaderView::Fixed);
    2. horizontalHeader()->setResizeMode(QHeaderView::Interactive);
    To copy to clipboard, switch view to plain text mode 

    I see absolutely no difference in behaviour -- I mean, both are interactively resizeable.
    Something must be mixing it up. QHeaderView::Fixed should do the trick. At least it does for me with Qt 4.2.3 and 4.3.0.
    J-P Nurmi

  3. #3
    Join Date
    Apr 2007
    Location
    Toruń, POLAND
    Posts
    24
    Thanks
    7
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: How to make headers fixed sized? (QTableWidget)

    Quote Originally Posted by jpn View Post
    Something must be mixing it up. QHeaderView::Fixed should do the trick. At least it does for me with Qt 4.2.3 and 4.3.0.
    Could persistent editors for each cell be the cause? I use Qt 4.3.0.

    I set non-clickable flag for each header, but I tried with and without -- still fixed mode does not work.

    have a nice day, bye

  4. #4
    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: How to make headers fixed sized? (QTableWidget)

    I assume something minimal like this works:
    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char* argv[])
    4. {
    5. QApplication a(argc, argv);
    6. QTableWidget table(5, 2);
    7. table.horizontalHeader()->setResizeMode(QHeaderView::Fixed);
    8. table.verticalHeader()->setResizeMode(QHeaderView::Fixed);
    9. for (int row = 0; row < table.rowCount(); ++row)
    10. {
    11. for (int col = 0; col < table.columnCount(); ++col)
    12. {
    13. table.setItem(row, col, item);
    14. table.openPersistentEditor(item);
    15. }
    16. }
    17. table.show();
    18. return a.exec();
    19. }
    To copy to clipboard, switch view to plain text mode 
    Could you try filling the example above with steps you've made in the actual project to make the example reproduce the problem?
    J-P Nurmi

  5. #5
    Join Date
    Apr 2007
    Location
    Toruń, POLAND
    Posts
    24
    Thanks
    7
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: How to make headers fixed sized? (QTableWidget)

    JPN, thank your for the answer.

    I were extending and extending this small example code, and when it reached 210 lines and I didn't manage to reproduce the fixed/interactive bug I was a bit worried :-)

    But luckily I pinned it down -- with each setRowCount or setColumnCount the resize mode is resetted! However, and this is really odd, when you create your table not like this
    QTableWidget(parent)
    but
    QTableWidget(0,0,parent)
    you can later on setColumn/Row count as you like and still resize mode will be properly kept.

    Once again, thank you for your help.

    have a nice day, bye

Similar Threads

  1. Compiling with Qmake/Make
    By VireX in forum Newbie
    Replies: 25
    Last Post: 22nd February 2007, 06: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.