PDA

View Full Version : QTableView appropriate size



YuriyRusinov
27th June 2006, 12:40
Hello !

I have form with tableView. Code is

class Form : public QDialog
{
...
QTableView *tableView;
...
};

class SearchTableModel : public QAbstractTableModel
{
...
};

class SearchTableDelegate : public QAbstractDelegate
{
...
};

Can I programmatically resize tableView and its parent form to appropriate size or fill all available space of tableView ?

--
Best regards,
Sincerely yours,
Yuriy Rusinov

jacek
27th June 2006, 12:47
or fill all available space of tableView ?
You can achieve this by setting resizeMode to QHeaderView::Stretch.

See QHeaderView::setResizeMode().

YuriyRusinov
27th June 2006, 13:12
OK, I did it, but form width is less than output text, which way I have to resize form in order to reduce horizontal scrollbar on tableView ?

Big Duck
27th June 2006, 14:06
hello,

I think I have the same problem. The last header in the QTreeView gets shrunk by the horizontal scroll bar.

The function:
void setStretchLastSection ( bool stretch )

does'nt work for me, although It seems it should.
I allow the user to resize header sections and save the size using QSettings.
After I resize them, the last header doesnt display its full size because of the horizontal scroll bar resizes it.

Let me know if you find a solution.
Many thanks,
Neil

YuriyRusinov
27th June 2006, 14:35
Of course, I post solution on this forum.

jacek
27th June 2006, 17:33
OK, I did it, but form width is less than output text, which way I have to resize form in order to reduce horizontal scrollbar on tableView ?
You could try QWidget::resize(), but I'm not sure how to get the exact size. Maybe QTreeView::columnWidth() will help.

YuriyRusinov
27th June 2006, 20:20
OK, I'll try.

YuriyRusinov
29th June 2006, 08:49
OK, I solved this problem using QTreeView and treemodel. Thanks.

Big Duck
29th June 2006, 11:33
The function:
void setStretchLastSection ( bool stretch )

does'nt work for me, although It seems it should.



:eek: well it does work for me after all, tried false instead of true :o