Unable to resize a QCanvas.
Hi everybody !
I'm testing QCanvas and I have a problem with it, I'm not able to resize it ... or the results doesn't correspond to what I expected to.
So I have a main application that have for the moment a QCanvas and a QCanvasView as member. In the init slot I do this :
Code:
void CanvasMainWindow::init()
{
pCanvas = 0;
pCanvasView = 0;
/////////////////////////////////////
// Construction and initialisation of canvas object
//
pCanvas = new QCanvas(this, "myCanvas");
Q_ASSERT( pCanvas );
pCanvas->resize(800, 600);
/////////////////////////////////////
// Construction and initialisation of canvasview object
//
pCanvasView = new QCanvasView(this, "myCanvasView");
Q_ASSERT( pCanvasView );
pCanvasView->setCanvas(pCanvas);
}
It compiles but when I start the application it only shows me my window with the right size but it only contains a small scrolling area which, I suppose, must be my QCanvas view attached to my QCanvas.
Despite I called the resize method of QCanvas, it looks not to be applied because the view is very small ... maybe something like 80x20.
So what is the problem with my code ?
Thanks in advance.
Re: Unable to resize a QCanvas.
I add the following line at the end of the init slot and my view fits to my main application :
Code:
setCentralWidget(pCanvasView);
Re: Unable to resize a QCanvas.
Quote:
Originally Posted by yellowmat
Despite I called the resize method of QCanvas, it looks not to be applied because the view is very small ... maybe something like 80x20.
So what is the problem with my code ?
You have set the size of the canvas itself, but the view has its own size --- you must set it too (you do it just like with any other widget).