Results 1 to 4 of 4

Thread: Resizing vertical header in QTableView

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2010
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Resizing vertical header in QTableView

    Hello and thanks for the response.

    I have a heavily styled widget with rounded borders and padding. The vertical header text is added automatically by when I insert a new row. These are numbers starting from 1.

    The single digit numbers cannot be seen. The header resizes if there is more then 9 rows - double digit header text -, which makes the single digit number visible and part of the second digit of the double digit ones. It works fine without styling.

    I use this code to insert the rows:

    Qt Code:
    1. QStandardItemModel * model =( ( QStandardItemModel * ) ( this->model() ) ); model->insertRows ( 0, 1 );
    2.  
    3. QBrush brush=QBrush(color);
    4. AddTextItem ( displayqueue_item.item1, ITEM1, 0, brush );
    5. AddPixmapItem ( "", displayqueue_item.item2, ITEM2, 0, brush );
    To copy to clipboard, switch view to plain text mode 

    As a workaround, I added an extra space to every header text after calling insertRow().

    Qt Code:
    1. for( int i=model->rowCount(); i>0; --i)
    2. model->setHeaderData(i-1, Qt::Vertical, QString("%1 ").arg(i));
    To copy to clipboard, switch view to plain text mode 

    This is now looks right until the style is changed again. Is this a bug in the QT resizing algorithm?

  2. #2
    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: Resizing vertical header in QTableView

    Possibly, but you haven't really given us anything to go on. How is your heavily styled widget achieved; style sheets, global custom style, derived widget paint method ? Do you override QHeaderView and return a revised size hint? Do you style QHeaderView or just the QTableView (or whatever)?

Similar Threads

  1. Vertical Header For QTreeView
    By wirasto in forum Qt-based Software
    Replies: 1
    Last Post: 12th October 2010, 05:53
  2. Qtableview Vertical header order
    By Darthspawn in forum Qt Programming
    Replies: 4
    Last Post: 26th March 2010, 15:10
  3. No Sort Vertical Header
    By wirasto in forum Qt Programming
    Replies: 4
    Last Post: 1st July 2009, 10:54
  4. Replies: 3
    Last Post: 1st February 2008, 18:18
  5. Showing Icon in vertical header of a table
    By vishal.chauhan in forum Qt Programming
    Replies: 7
    Last Post: 15th January 2007, 10:44

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.