Qt 5.3 QWidget::paintEngine:不应再调用
Qt 5.3 QWidget::paintEngine : Should no longer be called
我正在将我的代码从Qt4.x移动到Qt5.3,我遇到了一个奇怪的Qt警告,显示在命令提示符中。没有错误或任何东西,但命令提示符将显示以下内容:
QWidget::paintEngine: Should no longer be called
QPainter::begin: Paint device returned engine == 0, type: 1
QPainter::setClipRegion: Painter not active
QPainter::setClipRect: Painter not active
我想我把它缩小到了一个类别:标题:
#pragma once
#include <QtCoreqmetaobject.h>
#include <QtWidgetsQwidget.h>
#include <QtWidgetsQslider.h>
#include <QtwidgetsQpushbutton.h>
#include <QtwidgetsQcheckbox.h>
#include "MyGLWindow.h"
#include <QtWidgetsQHboxLayout>
#include <QtWidgetsQVboxLayout>
#include <QtWidgetsqmenubar.h>
#include <QtWidgetsqlabel.h>
class MeWidg : public QGLWidget
{
public:
QTimer myTimer;
bool testToggle;
float testRow;
bool noToggle;
MyGLWindow *gameGLWindow;
MeWidg();
private:
void myUpdate();
void loadModel();
};
和来源:
#include "MeWidg.h"
#include "DebugMenu.h"
MeWidg::MeWidg()
{
QVBoxLayout* mainLayout=new QVBoxLayout();
setLayout(mainLayout);
QHBoxLayout* setUpLayout=new QHBoxLayout();
setWindowTitle("Game Creator");
QHBoxLayout *game =new QHBoxLayout();
gameGLWindow=new MyGLWindow();
debugMenu.initialize(setUpLayout);
debugMenu.addLayout("World");
QMenuBar* mb=new QMenuBar();
mb->setMaximumHeight(20);
QMenu* fileMenu = mb->addMenu("File");
QAction* action;
fileMenu->addAction(action = new QAction("Load Project", this));
//action->setShortcut(QKeySequence::Open);
//connect(action, SIGNAL(triggered()), this, SLOT(loadObj()));
fileMenu->addAction(action = new QAction("Save Project", this));
//action->setShortcuts(QKeySequence::Save);
//connect(action, SIGNAL(triggered()), this, SLOT(saveNative()));
fileMenu->addSeparator();
fileMenu->addAction(action = new QAction("Load level", this));
//action->setShortcuts(QKeySequence::Save);
//connect(action, SIGNAL(triggered()), this, SLOT(loadLVL()));
fileMenu->addAction(action = new QAction("Save Level", this));
//action->setShortcuts(QKeySequence::Save);
//connect(action, SIGNAL(triggered()), this, SLOT(saveNative()));
fileMenu->addSeparator();
fileMenu->addAction(action = new QAction("Close", this));
//action->setShortcuts(QKeySequence::Save);
//connect(action, SIGNAL(triggered()), this, SLOT(saveNative()));
QMenu* objectMenu=mb->addMenu("Objects");
objectMenu->addAction(action=new QAction("Load Model", this));
//action->setShortcut(QKeySequence::Open);
connect(action, &QAction::triggered, [=]() { this->loadModel();});
objectMenu->addAction(action=new QAction("Add Light", this));
//action->setShortcut(QKeySequence::Open);
//connect(action, SIGNAL(triggered()), this, SLOT(loadObj()));
objectMenu->addAction(action=new QAction("Add Sound", this));
//action->setShortcut(QKeySequence::Open);
//connect(action, SIGNAL(triggered()), this, SLOT(loadObj()));
objectMenu->addAction(action=new QAction("Add Game Object", this));
//action->setShortcut(QKeySequence::Open);
//connect(action, SIGNAL(triggered()), this, SLOT(loadObj()));
mainLayout->addWidget(mb);
game -> addWidget(gameGLWindow,1, 0);
setUpLayout -> addLayout(game);
gameGLWindow->setMinimumHeight(600);
gameGLWindow->setMinimumWidth(500);
mainLayout->addLayout(setUpLayout, 1);
connect(&myTimer, &QTimer::timeout, [=]() { this->myUpdate(); });
myTimer.start(16);
}
void MeWidg::myUpdate()
{
debugMenu.update();
if(GetAsyncKeyState(VK_ESCAPE) && !noToggle)
{
noToggle=true;
debugMenu.toggleVisibility();
}
else if(!GetAsyncKeyState(VK_ESCAPE) && noToggle)
{
noToggle=false;
}
}
void MeWidg::loadModel()
{
gameGLWindow->loadModel();
}
有人知道我为什么收到这些警告吗?此外,我一直在使用的小部件都没有显示,唯一显示的是一个空白框,其中的布局曾经是。如果我不能弄清楚这一点,我将很长时间回到qt4.x.
您没有显示代码的相关部分。似乎有一些自定义小部件在其基类上调用paintEngine()
方法(这是不允许的)。通过查找paintEngine()
调用找到该小部件并修复它。
相关文章:
- 什么时候调用组成单元对象的析构函数
- 对RValue对象调用的LValue ref限定成员函数
- 为什么使用 "this" 指针调用派生成员函数?
- 函数调用中参数的顺序重要吗
- OpenGL - 在抛出"__gnu_cxx::recursive_init_error"实例后终止调用?
- 基于另一个成员参数将函数调用从类传递给它的一个成员
- 为什么我的C#代码在调用回C++COM直到Task时会暂停.等待/线程.加入
- 在c++类上调用void函数
- 为什么 std::unique 不调用 std::sort?
- 调用专用模板时出错"no matching function for call to [...]"
- 选择要调用的构造函数
- C++为什么尽管我调用了void函数,它却不起作用
- 构造函数正在调用一个使用当前类类型的函数
- 变量没有改变?通过向量的函数调用
- 没有为自己的结构调用列表推回方法
- 调用'begin(int [n])'没有匹配函数
- 什么时候调用析构函数
- 如何用参数值调用函数(仅在运行时已知)
- Qt 5.3 QWidget::paintEngine:不应再调用
- Qt:QWidget::paintEngine:不应再调用