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.
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++;
}
qTrackGrid::qTrackGrid(qDocumentView *parent)
: QWidget(parent),
count(0)
{
grid = new QGridLayout(this);
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++;
}
To copy to clipboard, switch view to plain text mode
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.
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);
}
qTrackView::qTrackView(QWidget *parent, vwd_SV iSV)
: QGraphicsView(parent),
SV(iSV),
buff(NULL),
size(0)
{
// create the scene
scene = new QGraphicsScene;
setScene(scene);
// update the view
updateView();
}
void qTrackView::resizeEvent(QResizeEvent *event)
{
fitInView(scene->sceneRect(), Qt::IgnoreAspectRatio);
}
To copy to clipboard, switch view to plain text mode
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...
Bookmarks