PDA

View Full Version : Suggestions Anyone:QTableView Grid



locus
23rd January 2007, 07:32
I have created a QDialog on top of which i have a QTableView, and a few buttons.

I would like to know what controls the size of the grid in the view.

I would like to have the width of the grid be the same size as the view's frame at all times (even as the view is being resized ie. being pulled at one end by the mouse cursor {see image attached}).

Meaning if the grid is in the so called client geometry of the view, i want the client geometry and the frame geometry of the table view to be equal.

I was thinking of subclassing the table view and probably calling setgeometry() within resizeEvent; at the risk of infinite recursion :o. Could that work?

Do i need to subclass QItemDelegate, or QabstractItemDelegate?

I am just trying to find a way to get it done, any suggestions are welcomed.

A bmp image is included in the zip attached, so everyone can get a graphical feel for what i'm taking about.

Thanks very much for your attention.

e8johan
23rd January 2007, 07:42
This is where layouts enter the picture. Let a layout resize your grid.

jpn
23rd January 2007, 07:46
QHeaderView is responsible for resizing columns. You can access it through QTableView::horizontalHeader(). Depending on how you want it to act, you can play with:

QHeaderView::setStretchLastSection()
QHeaderView::setResizeMode()
...

locus
23rd January 2007, 08:01
hey jpn,

Thanks man,

I'm checking it out now.