QDockWidget - QGlWidget - 当小部件从停靠栏拖出时无效可绘制

发布于 2024-12-11 14:44:20 字数 2112 浏览 0 评论 0原文

我的应用程序中有一个 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();
}

我该如何解决这个问题?。
我在这里看到了类似的问题:QScrollArea 中的 QGLWidget 说“无效的可绘制”,并且根据该帖子,我尝试删除我的小部件中的所有 setFixedSize() 函数,并将其替换为 setMinimumSize() 函数,但是但这并没有解决问题。有类似经历吗?你是怎么解决的?

I have a QDockWidget object in my application, which contains a QWidget object inside it. When my application runs, everything seems fine. However when I moved the widget from the QDockWidget (dragged it out from the Dock widget), I suddenly got these 10 lines of warning message on my console:

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

My main function is as follow:

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();
}

How can I solve this problem?.
I saw a similar question here : QGLWidget in QScrollArea says "invalid drawable", and based on that post, I tried to remove all the setFixedSize() function inside my widget and replace them with setMinimumSize() function, but that did not solve the problem. Any similar experience?. How did you solve it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不必在意 2024-12-18 14:44:20

如下所示更改您的 Dockwidget 属性并尝试

 performanceDockWidget->setAllowedAreas(Qt::AllDockWidgetAreas)

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

Change your Dockwidget property as given below and try

 performanceDockWidget->setAllowedAreas(Qt::AllDockWidgetAreas)

If that doesn't work as well, change your Dockwidget property to resizable and then try.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文