Results 1 to 12 of 12

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

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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 

  2. #2
    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

  3. #3
    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, 18:50
  2. Editable table header
    By bbarran in forum Qt Programming
    Replies: 4
    Last Post: 9th December 2010, 10:26
  3. Table Widget Vs. Table View
    By winston2020 in forum Qt Programming
    Replies: 2
    Last Post: 19th October 2008, 09:56
  4. How to customize horizontal header (diagonal header view)
    By vairamuthu.g in forum Qt Programming
    Replies: 4
    Last Post: 4th September 2008, 15:59
  5. horizontal header over two rows in tablewidget
    By Nippler in forum Qt Programming
    Replies: 2
    Last Post: 28th April 2008, 10: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
  •  
Qt is a trademark of The Qt Company.