UPDATE: Ok, I figured out that the use of QWidget::createWindowContainer has limitations regarding stacking order. I found a possible solution where the widget is inserted in a QMdiArea. This solved the clipping problem for Windows. Unfortunately on OS X I am now getting the the same problem as with QGLWidget. On application startup a white rectangle is drawn at the top left corner of my main window. After some research it found the cause for it: It is a hidden toolbar with a widget in it. If I do not hide the the toolbar (in my code), the white rectangle is gone. Also when I show the toolbar in my application, the white rectangle goes away and won't appear again. Another remark, my QGLWidget is child of a parent widget which again is the central widget of my application. If I directly use the QGLWidget as the central widget, the problem also does not occur.
To sum it up:
- I have a QGLWidget with a parent QWidget as the central widget of my application.
- I have a hidden tool bar with a widget in it.
- When I start the application on OS X, a white rectangle appears at the top left corner of my application.
- The rectangle goes away after showing the toolbar.
- The problem does not occur if I do not hide the toolbar in my code or if I use the QGLWidget directly as the central widget.
Here is some simple demo code which shows the problem:
#include <QApplication>
#include <QMainWindow>
#include <QGLWidget>
#include <QToolBar>
#include <QMenuBar>
#include <QMenu>
int main(int argc, char *argv[])
{
//QCoreApplication::addLibraryPath("Qt/plugins");
main.setStyleSheet("background-color: black;");
main.setCentralWidget(central);
tb->addWidget(w);
tb->hide();
main.addToolBar(Qt::BottomToolBarArea, tb);
QMenu *m
= main.
menuBar()->addMenu
("View");
m->addAction(tb->toggleViewAction());
main.show();
main.resize(800, 600);
return app.exec();
}
#include <QApplication>
#include <QMainWindow>
#include <QGLWidget>
#include <QToolBar>
#include <QMenuBar>
#include <QMenu>
int main(int argc, char *argv[])
{
//QCoreApplication::addLibraryPath("Qt/plugins");
QApplication app(argc, argv);
QMainWindow main;
main.setStyleSheet("background-color: black;");
QWidget *central = new QWidget(&main);
QGLWidget *gl = new QGLWidget(central);
main.setCentralWidget(central);
QWidget *w = new QWidget();
QToolBar *tb = new QToolBar("Test");
tb->addWidget(w);
tb->hide();
main.addToolBar(Qt::BottomToolBarArea, tb);
QMenu *m = main.menuBar()->addMenu("View");
m->addAction(tb->toggleViewAction());
main.show();
main.resize(800, 600);
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Unfortunately I can't upload an image of the problem because I currently always getting an error while trying to upload the file.
To me this looks like a bug in Qt or am I doing something wrong?
Thank,
Marcus
Bookmarks