PDA

View Full Version : Problem adding QGLWidget to QGridLayout



Marga
21st September 2011, 13:02
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:


void setupUi(QMainWindow *mainWindow)
{
if (mainWindow->objectName().isEmpty())
mainWindow->setObjectName(QString::fromUtf8("mainWindow"));
mainWindow->resize(800, 600);

//grid layout
gridLayout = new QGridLayout();
layoutWidget = new QWidget(mainWindow);
layoutWidget->setLayout(gridLayout);
mainWindow->setCentralWidget(layoutWidget);

//openGL window
windowOpenGL = new GLWidget(mainWindow);

//Splitter
dirBrowser = new QSplitter(mainWindow); //define the where the browsers will be contained

//... here I add QListViews and QTreeViews to the splitter

//Text view
textView = new QTextEdit(mainWindow);
textView->setReadOnly(true);

gridLayout->addWidget(dirBrowser, 0, 0, 1, 1);
gridLayout->addWidget(textView, 1, 0, 1, 1);
gridLayout->addWidget(windowOpenGL, 2, 0, 1, 1);

// .. here there are some connects(...)
}


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!

Rachol
21st September 2011, 14:34
Try if setting some small fixed size on QTextEdit object will help.

Marga
21st September 2011, 14:52
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!!