Results 1 to 3 of 3

Thread: Unable to resize a QCanvas.

  1. #1
    Join Date
    Jan 2006
    Posts
    162
    Thanks
    9
    Qt products
    Qt3
    Platforms
    Windows

    Default 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 :
    Qt Code:
    1. void CanvasMainWindow::init()
    2. {
    3. pCanvas = 0;
    4. pCanvasView = 0;
    5.  
    6. /////////////////////////////////////
    7. // Construction and initialisation of canvas object
    8. //
    9. pCanvas = new QCanvas(this, "myCanvas");
    10. Q_ASSERT( pCanvas );
    11. pCanvas->resize(800, 600);
    12.  
    13.  
    14. /////////////////////////////////////
    15. // Construction and initialisation of canvasview object
    16. //
    17. pCanvasView = new QCanvasView(this, "myCanvasView");
    18. Q_ASSERT( pCanvasView );
    19. pCanvasView->setCanvas(pCanvas);
    20. }
    To copy to clipboard, switch view to plain text mode 

    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.

  2. #2
    Join Date
    Jan 2006
    Posts
    162
    Thanks
    9
    Qt products
    Qt3
    Platforms
    Windows

    Default 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 :
    Qt Code:
    1. setCentralWidget(pCanvasView);
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default 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).

Similar Threads

  1. QCanvas Files not found
    By Kapil in forum Installation and Deployment
    Replies: 5
    Last Post: 24th March 2006, 08:36
  2. QCanvas Examples
    By Kapil in forum Qt Programming
    Replies: 6
    Last Post: 23rd March 2006, 14:12
  3. Replies: 7
    Last Post: 20th March 2006, 21:03
  4. postponing resize event
    By Honestmath in forum Qt Programming
    Replies: 11
    Last Post: 26th February 2006, 01:32
  5. How to get a QDockWidget to auto resize?
    By bitChanger in forum Qt Programming
    Replies: 4
    Last Post: 6th January 2006, 17:10

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.