Results 1 to 5 of 5

Thread: Resize QGLWidget

  1. #1
    Join Date
    Aug 2010
    Posts
    65
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Resize QGLWidget

    I have a program composed of a QMainWindow with a QGLWidget as its central widget. When I resize the main window, QGLWidget::resizeGL() is triggered (however, I currently have it do absolutely nothing). This is also visually displayed by the "background" of the MainWindow remaining as the QGLWidget's background color. As well, moving the mouse in the "new" parts of the widget triggers QGLWidget::mouseMoveEvent().

    However, the drawing isn't rescaled. Indeed, the image remains in its original scale and position, regardless of the resize event. As well, the "drawable" area of the QGLWidget isn't altered either. If I increase the main window and then translate an image (whether the image was opened before or after the resizing) to the "new" areas of the widget, it gets clipped at the original limits of the widget. I'm not even sure what code snippets to present because I don't know what could be causing this. As I've said, my ::resizeGL() is completely empty. If I change it to basically
    Qt Code:
    1. QGLWidget::resizeGL(int w, int h)
    2. {
    3. this->resize(w,h);
    4. }
    To copy to clipboard, switch view to plain text mode 
    nothing changes.

    Does QGLWidget have some "drawable" section I'm unaware of that doesn't get automatically resized?

    I've attached an image showing the problem, in case I didn't explain it well enough. The original size was the same as that clipping area, while the expanded area isn't drawable.
    image.jpg

  2. #2
    Join Date
    Oct 2007
    Location
    Lake Forest, CA, USA
    Posts
    132
    Thanks
    10
    Thanked 27 Times in 22 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: Resize QGLWidget

    Why don't you use layouts?
    Oleg Shparber

  3. #3
    Join Date
    Aug 2010
    Posts
    65
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Resize QGLWidget

    How would that help with my problem? As I've said, the problem isn't in resizing the QGLWidget. I've got plenty of indications that's already happening. The problem is in getting the "drawable" area of the QGLWidget to be resized with it, something I doubt layouts would help with.

  4. #4
    Join Date
    Oct 2007
    Location
    Lake Forest, CA, USA
    Posts
    132
    Thanks
    10
    Thanked 27 Times in 22 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: Resize QGLWidget

    Sorry, misread you question. You should actually not resize widget itself, but rerender its content according new widget size. Good sample Hello GL Example.
    Oleg Shparber

  5. #5
    Join Date
    Aug 2010
    Posts
    65
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Resize QGLWidget

    Thanks. Yeah, I had to make a call to glViewport() to redefine the GL context. That solved it, thanks.

Similar Threads

  1. QGLWidget and VBO
    By kaszewczyk in forum Newbie
    Replies: 1
    Last Post: 6th May 2010, 11:04
  2. QGLWidget
    By manmohan in forum Newbie
    Replies: 2
    Last Post: 5th June 2009, 13:54
  3. Can not use QGLWidget.
    By Teuniz in forum Installation and Deployment
    Replies: 3
    Last Post: 25th September 2007, 01:27
  4. QGLWidget bug
    By Wizard in forum Qt Programming
    Replies: 11
    Last Post: 31st August 2007, 12:23
  5. qGLWidget
    By mickey in forum Newbie
    Replies: 8
    Last Post: 24th February 2006, 01:30

Tags for this Thread

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.