QPainter 设备返回引擎 == 0,类型:3(在重新定义的 paint() 方法中)
QPainter device returned engine == 0, type: 3 (in re-defined paint() method)
我有一大块基于 Qt 的软件,运行在我们使用的所有现代机器上都很好。我们尝试 运行 在旧机器上编译软件,当我们尝试构建更大的场景时软件崩溃并出现以下错误:
程序中只有几个地方使用了 QPainter
,它在 [=13= 的继承 class 的重新定义方法 paint()
中],例如:
virtual void paint(QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
QStyledItemDelegate::paint(painter, option, index);
// ...
QApplication::style()->drawControl(QStyle::CE_PushButtonLabel, &buttonDelete, painter);
}
问题是 QPainter
出现此类问题的原因可能是什么?这可能与可用内存有关,因为它在所有现代机器上似乎都很好吗?有什么建议可以在这里完成吗?
older machine
+
the software crashes when we try to build bigger scenes
= 很可能 运行 内存不足。您可以安装内存不足处理程序以在发生这种情况时得到通知:
#include <cstdio>
#include <new>
void my_new_handler()
{
printf("Memory allocation failed, terminating\n");
std::set_new_handler(nullptr);
}
int main(int argc, char ** argv)
{
QApplication app(argc, argv);
std::set_new_handler(my_new_handler);
...
return app.exec();
}
我有一大块基于 Qt 的软件,运行在我们使用的所有现代机器上都很好。我们尝试 运行 在旧机器上编译软件,当我们尝试构建更大的场景时软件崩溃并出现以下错误:
程序中只有几个地方使用了 QPainter
,它在 [=13= 的继承 class 的重新定义方法 paint()
中],例如:
virtual void paint(QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
QStyledItemDelegate::paint(painter, option, index);
// ...
QApplication::style()->drawControl(QStyle::CE_PushButtonLabel, &buttonDelete, painter);
}
问题是 QPainter
出现此类问题的原因可能是什么?这可能与可用内存有关,因为它在所有现代机器上似乎都很好吗?有什么建议可以在这里完成吗?
older machine
+
the software crashes when we try to build bigger scenes
= 很可能 运行 内存不足。您可以安装内存不足处理程序以在发生这种情况时得到通知:
#include <cstdio>
#include <new>
void my_new_handler()
{
printf("Memory allocation failed, terminating\n");
std::set_new_handler(nullptr);
}
int main(int argc, char ** argv)
{
QApplication app(argc, argv);
std::set_new_handler(my_new_handler);
...
return app.exec();
}