Results 1 to 8 of 8

Thread: Resize qglwidget

  1. #1
    Join Date
    Mar 2011
    Posts
    34
    Qt products
    Qt4
    Platforms
    Windows

    Default Resize qglwidget

    Hi,

    I have a qWidget with a qglwidget an other form elements inside. How can I resize my qglwidget when i expand or reduce the qWidget?

    Thanks

  2. #2
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    52
    Thanked 42 Times in 42 Posts

    Default Re: Resize qglwidget

    Add qglWidget to the layout and then add layout to the qWidget.
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  3. #3
    Join Date
    Mar 2011
    Posts
    34
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Resize qglwidget

    An how I add the qglwidget to the layout?

  4. #4
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    52
    Thanked 42 Times in 42 Posts

    Default Re: Resize qglwidget

    Something along these lines:
    Qt Code:
    1. l->addWidget( qglWidget );
    2. this->setLayout( l );
    To copy to clipboard, switch view to plain text mode 
    And also RTM!
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  5. #5
    Join Date
    Mar 2011
    Posts
    34
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Resize qglwidget

    In this case, all the qwidget is surrounded by the qglwidget, all my buttons are seen in black.

  6. #6
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    52
    Thanked 42 Times in 42 Posts

    Default Re: Resize qglwidget

    If you don't add buttons to the layout that's what will happen (if I understand Your correctly).
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  7. #7
    Join Date
    Mar 2011
    Posts
    34
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Resize qglwidget

    I wish to add buttons to the layout:

    Qt Code:
    1. l->addWidget(ui->GLpanel);
    2. l->addLayout(ui->buttonInterface); //buttonInterface is a layout
    3. this->setLayout(l);
    To copy to clipboard, switch view to plain text mode 

    However, if I do this, I have a segmentation fault calling l->addLayout(...)

  8. #8
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    52
    Thanked 42 Times in 42 Posts

    Default Re: Resize qglwidget

    I see you're using designer, so for simplicity sake do this:
    1. place Your buttons and other widgets with designer
    2. place EMPTY layout (whatever type) into place that You want to have qglWidget (You can place inside this layout temporary QWidget for easier visualisation, because empty layout is 0 pix width/height - depending on others layouts)
    3. remove temporary QWidget and remember layout that this widget is in
    at this point logical structure is like this (layout's are nested):
    mainLayout (with all buttons + layout for glWidget)->glWidgetLayout (layout where you will place your glWidget)
    then in your constructor, after UI initialization simply use:
    Qt Code:
    1. ui->glWidgetLayout ->addWidget( glWidget );
    To copy to clipboard, switch view to plain text mode 
    Also see this article. There is ready project that You can examine, because You error is in lacking of knowledge about layouts (everything what You ask is in manual RTM)
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

Similar Threads

  1. QGLWidget resize not working
    By iKo in forum Qt Programming
    Replies: 1
    Last Post: 3rd December 2010, 22:37
  2. QGLWidget resize problem
    By Term Dickem in forum Qt Programming
    Replies: 0
    Last Post: 26th May 2010, 15:12
  3. QGLWidget and resize
    By themolecule in forum Qt Programming
    Replies: 1
    Last Post: 13th May 2008, 09:46
  4. QGLWidget Resize Problem
    By Sandip in forum Qt Programming
    Replies: 2
    Last Post: 28th February 2008, 07:47
  5. QGLWidget resize problem.
    By anderl in forum Qt Programming
    Replies: 2
    Last Post: 22nd January 2008, 09:57

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
  •  
Qt is a trademark of The Qt Company.