Results 1 to 6 of 6

Thread: How can I always show the horizontalHeader, even if the qtableview is empty?

  1. #1
    Join Date
    Jun 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Question How can I always show the horizontalHeader, even if the qtableview is empty?

    Currently when the tableview is empty, the horizontalheader will be automatically hidden. But I want it always shown. Is there anyway to do that?

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How can I always show the horizontalHeader, even if the qtableview is empty?

    did you try:
    pMyTable->horizontalHeader()->setVisible(true); ?
    Last edited by high_flyer; 29th June 2010 at 09:28.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jun 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How can I always show the horizontalHeader, even if the qtableview is empty?

    yeah, but it has no effect.

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How can I always show the horizontalHeader, even if the qtableview is empty?

    Can you show your code?
    Is the table generated in code, or designer?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Jun 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How can I always show the horizontalHeader, even if the qtableview is empty?

    Sorry, I cannot show my code.
    The table is generated by code, and it's totally following the model/view architecture. Basically it looks lke this:

    class A: public QAbstractTableModel{...};
    class B: pulbic QSortFilterProxyModel{...};
    class C: public QTableView{...};

    A a;
    B b;
    C c;

    b.setModel(&a);
    c.setModel(&b);

    Here c is the table. Everything just works fine, except that the horizontalHeader of c automatically disappears when I hide all columns in c. I just want the horizontalHeader always shown.

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How can I always show the horizontalHeader, even if the qtableview is empty?

    when I hide all columns in c
    This is not the same as:
    Currently when the tableview is empty
    Hidden is not same as empty.

    You probably will have to manually call showSection() on the hidden columns,when you hide you columns.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. QTableView does not show data
    By waynew in forum Newbie
    Replies: 4
    Last Post: 11th December 2009, 23:38
  2. QTableView showing empty fields
    By ederbs in forum Qt Programming
    Replies: 5
    Last Post: 4th October 2007, 00:30
  3. QTableView from SQLite, empty!
    By grellsworth in forum Qt Programming
    Replies: 9
    Last Post: 3rd July 2007, 20:32
  4. QTableView not corectly showing empty fields
    By Sergey B. in forum Qt Programming
    Replies: 4
    Last Post: 15th June 2007, 08:18
  5. Resizing QTableView's horizontalHeader
    By Jimmy2775 in forum Qt Programming
    Replies: 4
    Last Post: 20th December 2006, 00:14

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.