Results 1 to 8 of 8

Thread: QTableWidget do not hide headers on resize, what to do?

  1. #1
    Join Date
    Aug 2010
    Posts
    107
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy QTableWidget do not hide headers on resize, what to do?

    Hello Qt community!
    I have a QTableWidget and I don’t want its headers to resize forever.
    I know that I can hide the scrollbar, but this still doesn’t solve my problem.
    Let’s say that I have 3 headers in my QTableWidget, named “One”, “Two” and “Three”. I want to be able to resize each of these headers without the text of the others to be hidden. So, basically I need a minimum ‘resize rate’, which has to be set to the width that the text of each header captures.

    Sorry if I am not fully understandable.
    Here are an example screenshot of what I don’t want to happen:

    7yHkB.png

    As you see, I’ve resized “Two”, but the text of “Three” has been hidden, and I’ve turned scrollbars off. I want to be able to resize each header (column) till the point of not hiding the text of the other headers.

    Thanks in advance for any help

  2. #2
    Join Date
    Oct 2011
    Location
    Germany
    Posts
    27
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget do not hide headers on resize, what to do?

    Qt Code:
    1. QHeaderView *header = yourTableWidget->horizontalHeader();
    2. header->setResizeMode(QHeaderView::Stretch);
    To copy to clipboard, switch view to plain text mode 
    Insanity: doing the same thing over and over again and expecting different results.
    Albert Einstein

  3. #3
    Join Date
    Aug 2010
    Posts
    107
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget do not hide headers on resize, what to do?

    Thanks for the answer but this ones disables the Resizing..
    We want to be able to resize columns but if u resize the one before the last one don't continue resizing as much as u want ( see previous screenshot )..

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QTableWidget do not hide headers on resize, what to do?

    What do you expect to happen when the user resizes the whole window?

  5. #5
    Join Date
    Aug 2010
    Posts
    107
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget do not hide headers on resize, what to do?

    What should i expect? Tablewidget becomes bigger, and collumns become bigger..
    Why question this.. this has nothing to do with my question ( i think )

    Do you understand what i ask?

  6. #6
    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: QTableWidget do not hide headers on resize, what to do?

    Quote Originally Posted by Bong.Da.City View Post
    Why question this.. this has nothing to do with my question ( i think )
    It has a lot to do with your question. Especially the behaviour you want when the window is resized down.
    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.


  7. #7
    Join Date
    Aug 2010
    Posts
    107
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget do not hide headers on resize, what to do?

    OK Think for now, let's says i have maximum and minimum to window and i can't resize it..

    How to do what i say in 1st post?

  8. #8
    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: QTableWidget do not hide headers on resize, what to do?

    Then you need to control resizing of the header manually either by reimplementing some virtual methods in QHeaderView subclass or by connecting to QHeaderView::sectionResized() signal (or both).
    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.


Similar Threads

  1. Resizing headers view in the QTableWidget
    By jano_alex_es in forum Qt Programming
    Replies: 1
    Last Post: 27th January 2010, 10:55
  2. QTableWidget headers
    By vieraci in forum Qt Programming
    Replies: 2
    Last Post: 18th July 2009, 08:25
  3. QToolBox + resize + hide
    By eleanor in forum Newbie
    Replies: 14
    Last Post: 24th October 2007, 19:41
  4. trying to union two headers of QTableWidget
    By uygar in forum Qt Programming
    Replies: 2
    Last Post: 25th September 2007, 15:55
  5. Replies: 3
    Last Post: 29th August 2006, 15:07

Tags for this Thread

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.