Resizing QGraphicsView inside a QGridLayout
Hi,
I am trying to insert a series of qgraphicsviews into the cells of a dynamically expanded qgridlayout.
Here is a bit from the grid class.
Code:
qTrackGrid::qTrackGrid(qDocumentView *parent)
count(0)
{
setLayout(grid);
}
qTrackGrid::~qTrackGrid()
{
// delete everything
for(int cc = 0; cc < count; cc++)
delete views[cc];
delete grid;
}
void qTrackGrid::addTrackView(vwd_SV SV)
{
// add a new qTrackView to the next available position in the grid
// hear we are enforcing that the column width be a maximum of 2
int cRow = grid->rowCount();
int cCol = grid->columnCount();
int row = count / 2;
int col = count % 2;
qTrackView* tv = new qTrackView(this, SV);
tv->setVisible(true);
grid->addWidget(tv->viewport(), row, col);
views.append(tv);
qDebug() << grid->cellRect(row, col);
count++;
}
I would like to use something like the following code in the qTrackView class I have inserted into the grid to make sure that the image scales and displays according to the current size of the qTrackGrid widget.
Code:
qTrackView
::qTrackView(QWidget *parent, vwd_SV iSV
) SV(iSV),
buff(NULL),
size(0)
{
// create the scene
setScene(scene);
// update the view
updateView();
}
{
fitInView(scene->sceneRect(), Qt::IgnoreAspectRatio);
}
I dont seem to be getting the resizing working as it would if the QGraphicsView object was inserted into the the widget without it being a cell of a QGridLayout.
I am setting up the qTrackView class with a QGraphicsScene as you can see from the constructor.
Its obvious that I am missing something just havent got my head around it yet.
Thanks,
Dave...
Re: Resizing QGraphicsView inside a QGridLayout
Quote:
Originally Posted by
mckinnon
I dont seem to be getting the resizing working as it would if the QGraphicsView object was inserted into the the widget without it being a cell of a QGridLayout.
I don't understand what you want to say.
Do you mean that the objects in the graphicsview do not get resized if you do not add the view to the grid layout?
Re: Resizing QGraphicsView inside a QGridLayout
No, sorry I am trying to say that the graphicsview objects dont resize properly when they are in the gridlayout.
But they do resize properly when they are not.
Any ideas?
Re: Resizing QGraphicsView inside a QGridLayout
I'd play with the size policies of the graphics view (and its neighbours) as well as the minimumSize and maximumSize properties of the graphics view.