Results 1 to 12 of 12

Thread: How to set two rows in a table view Horizontal header?

  1. #1
    Join Date
    Mar 2009
    Location
    Hyderabad, India
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default How to set two rows in a table view Horizontal header?

    Hi,
    We need to insert two rows in a table view header. But the QHeaderView looks like supporting only single row in a table header. How can we achieve to insert two rows in a table header.



    Thanks in advance.
    Regards,
    sivollu

  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: How to set two rows in a table view Horizontal header?

    Please search the forum. As far as I remember the issue has already been brought up. From what I see even the "Similar threads" block on the bottom of this page suggests a thread with a solution.
    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.


  3. #3
    Join Date
    Mar 2009
    Location
    Hyderabad, India
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to set two rows in a table view Horizontal header?

    Sorry iam not able to find the solution.
    can you please view the attachment and suggest the procedure.
    Attached Images Attached Images

  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: How to set two rows in a table view Horizontal header?

    This thread might give you some ideas.

    http://www.qtcentre.org/forum/f-qt-p...view-4904.html

  5. #5
    Join Date
    Mar 2009
    Location
    Hyderabad, India
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to set two rows in a table view Horizontal header?

    I have already tried the same, but iam not getting exactly what i need to show, when i used the verticallayout, its clearly differentiating the two headers, but in my case i want to have single horizontal headerview and in that one of the header should contain multiple headers.(please view the attachment). please guide me the approach.

  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: How to set two rows in a table view Horizontal header?

    I would subclass QHeaderView and reimplement most of it. But it's much work, unfortunately. QHeaderView is a very incomplete class that was probably meant to be finished in some undefined future that never came to be...
    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
    Jan 2008
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to set two rows in a table view Horizontal header?

    Try
    this

  8. #8
    Join Date
    Jul 2006
    Location
    Catalunya - Spain
    Posts
    117
    Thanks
    16
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to set two rows in a table view Horizontal header?

    take a look at this :

    QEXtendedGridView ( at qt-apps.org )
    Last edited by jpujolf; 20th April 2009 at 13:57. Reason: updated contents & avoid "spam"

  9. #9
    Join Date
    Mar 2009
    Location
    Hyderabad, India
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to set two rows in a table view Horizontal header?

    Hi,
    We downloaded the HierarchicalHeaderviewhttp://qt-apps.org/content/show.php/...content=103154 from QT-Apps. We are pleased to see the source code. Thank you for providing the details.

    How can i add rows and columns to this table view. I got lost with the ExampleModel class.

    regards,
    sivollu

  10. #10
    Join Date
    Jan 2008
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to set two rows in a table view Horizontal header?

    See Model\View programming in QT docs.

    ExampleModel is for data in table. It contains _headerModel. _headerModel discribes header structure.
    If you want add rows in table, implement rowCount in Example model (now it returns 0, i.e. no rows), and handle DisplayRole in data.
    Qt Code:
    1. QVariant data(const QModelIndex& index, int role) const
    2. {
    3. if(role==Qt::UserRole)
    4. {
    5. v.setValue((QObject*)&_headerModel);
    6. return v;
    7. }
    8. if(role==Qt::DisplayRole && index.isValid())
    9. {
    10. return QString("row %1 column %2").arg(index.row()).arg(index.column());
    11. }
    12. return QVariant();
    13. }
    To copy to clipboard, switch view to plain text mode 

  11. #11
    Join Date
    Mar 2009
    Location
    Hyderabad, India
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: How to set two rows in a table view Horizontal header?

    Hi Barmaglodd,
    I tried reimplementing the "insertRows" function. Called "beginInsertRows" and "endInsertRows()". But i get lost on what should we put between these two statements inside the function insertRows.

    We are trying to insert rows in the example code provided by you before.

    Request you to provide us a code snippet on how to insert rows into the table.


    With Regards,
    Sivollu

  12. #12
    Join Date
    Jan 2008
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to set two rows in a table view Horizontal header?

    Sorry for late answer.
    Where do you want to reimplement insertRows? If for table data, i realy recomend you read Model\View programming in Qt docs and Qt demos and examples. If you reimplement it for header model, it's a wrong way, header model is a tree not a table.

Similar Threads

  1. How to edit Horizontal Header Item in QTableWidget
    By ioannis in forum Qt Programming
    Replies: 6
    Last Post: 5th March 2013, 19:50
  2. Editable table header
    By bbarran in forum Qt Programming
    Replies: 4
    Last Post: 9th December 2010, 11:26
  3. Table Widget Vs. Table View
    By winston2020 in forum Qt Programming
    Replies: 2
    Last Post: 19th October 2008, 10:56
  4. How to customize horizontal header (diagonal header view)
    By vairamuthu.g in forum Qt Programming
    Replies: 4
    Last Post: 4th September 2008, 16:59
  5. horizontal header over two rows in tablewidget
    By Nippler in forum Qt Programming
    Replies: 2
    Last Post: 28th April 2008, 11:33

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.