PDA

View Full Version : QTableView +rowHeight



freeskydiver
24th May 2007, 23:03
I have a QTableView and all is ready, but I can't setup the rowHeight property. Who can help me? thanks in advance...

marcel
24th May 2007, 23:21
How exactly do you use setRowHeight?

darksaga
24th May 2007, 23:25
this should do what you want:



QTableView m_tableView = new QTableView(this);
m_tableView->verticalHeader()->setDefaultSectionSize(20); //setHeight
m_tableView->setModel(myModel);

freeskydiver
24th May 2007, 23:34
How exactly do you use setRowHeight?

Yes, but this property want setup for each row.
I look for a thing like
setDefaultRowHeight(20);

freeskydiver
24th May 2007, 23:38
this should do what you want:




m_tableView->verticalHeader()->setDefaultSectionSize(20); //setHeight



Well, nice name for this function ;) But this work not, too. ;( I got no changing.
Sorry, I test now with this function setResizeMode() function inherent. ;)

jpn
24th May 2007, 23:48
As a side note (and like darksaga's example shows), QHeaderView::setDefaultSectionSize() must be called before attaching a model to the table view.

darksaga
24th May 2007, 23:50
Well, nice name for this function ;) But this work not, too. ;( I got no changing.
Sorry, I test now with this function setResizeMode() function inherent. ;)

Had also probs with the rowheight when i used QTableView first.

My experience is that it depends on the order how you setup your model & tabel and where you call


m_tableView->verticalHeader()->setDefaultSectionSize(20);


Try to call setDefaultSectionSize @ a different place.

afaik, it will always work with the order I posted above.

freeskydiver
24th May 2007, 23:51
Well, nice name for this function ;) But this work not, too. ;( I got no changing.
Sorry, I test now with this function setResizeMode() function inherent. ;)

How anytime, the error to sit in the front of the monitor ;)
I have later used resizeRowsToContents();

darksaga
24th May 2007, 23:58
Be careful:

If you have a table with many rows & columns resizeRowsToContents && resizeColumnsToContents could slow down your app drastically.

in the project I'm currently developing I had to ban these due to servere slowdowns...