Results 1 to 3 of 3

Thread: Problem adding QGLWidget to QGridLayout

  1. #1
    Join Date
    Sep 2011
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Problem adding QGLWidget to QGridLayout

    Hello all,

    I have a QGridLayout set up, where I insert my widgets. I have 3 widgets: QSplitter (dirBrowser), a QTextEdit (textView) and a QGLWidget (windowOpenGL). My code is the following:

    Qt Code:
    1. void setupUi(QMainWindow *mainWindow)
    2. {
    3. if (mainWindow->objectName().isEmpty())
    4. mainWindow->setObjectName(QString::fromUtf8("mainWindow"));
    5. mainWindow->resize(800, 600);
    6.  
    7. //grid layout
    8. gridLayout = new QGridLayout();
    9. layoutWidget = new QWidget(mainWindow);
    10. layoutWidget->setLayout(gridLayout);
    11. mainWindow->setCentralWidget(layoutWidget);
    12.  
    13. //openGL window
    14. windowOpenGL = new GLWidget(mainWindow);
    15.  
    16. //Splitter
    17. dirBrowser = new QSplitter(mainWindow); //define the where the browsers will be contained
    18.  
    19. //... here I add QListViews and QTreeViews to the splitter
    20.  
    21. //Text view
    22. textView = new QTextEdit(mainWindow);
    23. textView->setReadOnly(true);
    24.  
    25. gridLayout->addWidget(dirBrowser, 0, 0, 1, 1);
    26. gridLayout->addWidget(textView, 1, 0, 1, 1);
    27. gridLayout->addWidget(windowOpenGL, 2, 0, 1, 1);
    28.  
    29. // .. here there are some connects(...)
    30. }
    To copy to clipboard, switch view to plain text mode 


    Using this code as it is, the window does not display the OpenGL window. However, if I don't add the QTextEdit to the grid layout, it displays normally. The strange thing is that if instead of adding QTextEdit to the grid I add, for a example, a simple button, the OpenGL widget is displayed correctly as well.

    What am I missing??? I would appreciate SO MUCH your help!!

    Thanks in advance!
    Last edited by Marga; 21st September 2011 at 13:25.

  2. #2
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: Problem adding QGLWidget to QGridLayout

    Try if setting some small fixed size on QTextEdit object will help.
    Don't write a post just to thank someone, use "Thanks" button.

  3. The following user says thank you to Rachol for this useful post:

    Marga (21st September 2011)

  4. #3
    Join Date
    Sep 2011
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Problem adding QGLWidget to QGridLayout

    Hi Rachol,

    Thanks!! I have tried setting the size on QTextEdit doing textView->resize(10,10), for example, and it does not work. However, I if a set a minimum height to the openGL window, it does appear on the screen!

    I wonder why this happens with the QGLWidget... I haven't come across other situation where a widget is suddenly resized to size 0! What do you think?

    Thanks a lot!!

Similar Threads

  1. Adding QGLWidget to QGraphicsScene problem
    By sanjayshelke in forum Qt Programming
    Replies: 10
    Last Post: 26th April 2016, 15:03
  2. QGridlayout problem
    By raju@123 in forum Qt Programming
    Replies: 2
    Last Post: 24th September 2010, 22:03
  3. QGridLayout problem
    By cae in forum Newbie
    Replies: 2
    Last Post: 30th November 2009, 09:53
  4. error when adding signal slot to a QGLWidget based class
    By john_god in forum Qt Programming
    Replies: 2
    Last Post: 11th April 2009, 23:31
  5. Replies: 0
    Last Post: 7th April 2008, 14:27

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.