PDA

View Full Version : How to set two rows in a table view Horizontal header?



sivollu
9th April 2009, 16:16
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

wysota
9th April 2009, 22:46
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.

sivollu
10th April 2009, 10:14
Sorry iam not able to find the solution.
can you please view the attachment and suggest the procedure.

ChrisW67
10th April 2009, 11:08
This thread might give you some ideas.

http://www.qtcentre.org/forum/f-qt-programming-2/t-advanced-qtableview-4904.html

sivollu
14th April 2009, 09:28
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.

wysota
14th April 2009, 22:14
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...

Barmaglodd
20th April 2009, 09:06
Try
this (http://qt-apps.org/content/show.php/HierarchicalHeaderView?content=103154) :)

jpujolf
20th April 2009, 12:53
take a look at this :

QEXtendedGridView ( at qt-apps.org ) (http://www.qtcentre.org/forum/f-qt-software-16/t-qextendedgridview-20392.html)

sivollu
21st April 2009, 15:39
Hi,
We downloaded the HierarchicalHeaderviewhttp://qt-apps.org/content/show.php/HierarchicalHeaderView?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

Barmaglodd
23rd April 2009, 04:47
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.


QVariant data(const QModelIndex& index, int role) const
{
if(role==Qt::UserRole)
{
QVariant v;
v.setValue((QObject*)&_headerModel);
return v;
}
if(role==Qt::DisplayRole && index.isValid())
{
return QString("row %1 column %2").arg(index.row()).arg(index.column());
}
return QVariant();
}

sivollu
25th April 2009, 16:09
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

Barmaglodd
29th April 2009, 04:57
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.