我的应用程序中有一个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在QScrollArea说"无效drawable",并基于该帖子,我试图删除我的小部件内的所有setFixedSize()
函数,并用setMinimumSize()
函数代替它们,但这并没有解决问题。有类似的经历吗?你是怎么解决的?
按如下所示更改Dockwidget属性并尝试
performanceDockWidget->setAllowedAreas(Qt::AllDockWidgetAreas)
如果这不起作用,将您的Dockwidget属性更改为可调整大小,然后尝试。