QDockWidget - QGlWidget - 从窗口拖出窗口小部件时无效的drawable

时间:2011-10-23 18:36:08

标签: c++ qt qglwidget qdockwidget

我的应用程序中有一个QDockWidget对象,其中包含一个QWidget对象。当我的应用程序运行时,一切似乎都很好但是,当我从QDockWidget移动小部件(从Dock小部件中拖出它)时,我突然在我的控制台上收到了这10行警告消息:

2011-10-23 21:06:22.296 PerformanceVisualization[42898:903] invalid drawable
2011-10-23 21:06:22.298 PerformanceVisualization[42898:903] invalid drawable
2011-10-23 21:06:22.299 PerformanceVisualization[42898:903] invalid drawable
2011-10-23 21:06:22.300 PerformanceVisualization[42898:903] invalid drawable
2011-10-23 21:06:22.300 PerformanceVisualization[42898:903] invalid drawable
2011-10-23 21:06:22.301 PerformanceVisualization[42898:903] invalid drawable
2011-10-23 21:06:22.302 PerformanceVisualization[42898:903] invalid drawable
2011-10-23 21:06:22.303 PerformanceVisualization[42898:903] invalid drawable
2011-10-23 21:06:22.304 PerformanceVisualization[42898:903] invalid drawable
2011-10-23 21:06:22.304 PerformanceVisualization[42898:903] invalid drawable

我的主要功能如下:

int main(int argc, char *argv[])
{
    srand(1);
    QApplication app(argc, argv);
    PerformanceModule *performanceModuleWidget = new PerformanceModule();// a QWidget object
    QMainWindow window;

    QDockWidget *performanceDockWidget = new QDockWidget(QObject::tr("Performance Visualization"), &window);
    performanceDockWidget->setWindowTitle("Performance Visualization Dock");
    performanceDockWidget->setAllowedAreas(Qt::LeftDockWidgetArea);
    performanceDockWidget->setWidget(performanceModuleWidget);

    //performanceDockWidget->show();

    window.addDockWidget(Qt::LeftDockWidgetArea, performanceDockWidget);
    //window.menuBar()->addAction(performanceDockWidget->toggleViewAction());
    //performanceDockWidget->hide(); // explicitly hidden
    window.show();

    return app.exec();
}

我该如何解决这个问题?。我在这里看到了一个类似的问题:QGLWidget in QScrollArea says "invalid drawable",基于该帖子,我试图删除我的小部件中的所有setFixedSize()函数用setMinimumSize()函数替换它们,但这并没有解决问题。有类似的经历吗?你是怎么解决的?

1 个答案:

答案 0 :(得分:0)

更改您的Dockwidget属性,如下所示,然后尝试

 performanceDockWidget->setAllowedAreas(Qt::AllDockWidgetAreas)

如果这不起作用,请将Dockwidget属性更改为可调整大小,然后尝试。