Qt - 创建 QPainter
我正在尝试在程序中重写方法 paintEvent
并更改它。
void MainWindow::paintEvent(QPaintEvent *event)
{
QRegion reg = this->bgPixmapHandle->rect();
QPainter painter(this);
painter.setClipRegion(reg);
painter.drawImage(bgPixmapHandle->rect(), bgPixmapHandle);
painter.end();
}
在这里,我尝试更改我的 bg
图像。 但我在线遇到错误:QPainter Painter(this);
错误:变量“QPainter画家”是 已初始化,尽管类型是 不完整
I'm trying to rewrite method paintEvent
in my programm and change it.
void MainWindow::paintEvent(QPaintEvent *event)
{
QRegion reg = this->bgPixmapHandle->rect();
QPainter painter(this);
painter.setClipRegion(reg);
painter.drawImage(bgPixmapHandle->rect(), bgPixmapHandle);
painter.end();
}
Here I try to change my bg
image. But I got an error on line: QPainter painter(this);
Error: Variable 'QPainter painter' is
initialized, though the type is
incomplete
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
包含 QPainter 头文件。 QPainter 类仅在您包含在该翻译单元中的 Qt 标头之一中向前声明。
Include QPainter header file. QPainter class is only forward declared in one of the Qt headers you're including in that translation unit.
你包括吗? Qt 非常喜欢前向声明类,这会导致此类神秘错误。
Are you including ? Qt is a big fan of forward declaration of classes, which causes such cryptic errors.