以下应用程序在mainWindow->show();
#include <QApplication>
#include <QFrame>
#include <QPixmap>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Q_INIT_RESOURCE(resources);
QPixmap pix;
pix.load(":/resources/images/app/icon_glow.png");
QFrame *mainWindow = new QFrame;
mainWindow->setWindowIcon(QIcon(pix));
mainWindow->show();
return a.exec();
}
在mainWindow->setWindowIcon(QIcon(pix));
注释掉后,一切正常。否则,回溯(SEGFAULT,尝试取消引用0x8;看起来像某个地方缺少nullptr检查)是:
0 ?? /usr/local/Qt32/5.3/gcc/plugins/platforms/libqxcb.so 0xf4991138
1 ?? /usr/local/Qt32/5.3/gcc/plugins/platforms/libqxcb.so 0xf4982d4c
2 ?? /usr/local/Qt32/5.3/gcc/plugins/platforms/libqxcb.so 0xf498e7e3
3 ?? /usr/local/Qt32/5.3/gcc/plugins/platforms/libqxcb.so 0xf498f0f4
4 QWindowPrivate::applyCursor() /usr/local/Qt32/5.3/gcc/lib/libQt5Gui.so.5 0xf7517942
5 QWindowPrivate::setCursor(QCursor const*) /usr/local/Qt32/5.3/gcc/lib/libQt5Gui.so.5 0xf75179f7
6 QWindow::setCursor(QCursor const&) /usr/local/Qt32/5.3/gcc/lib/libQt5Gui.so.5 0xf7517b16
7 ?? /usr/local/Qt32/5.3/gcc/lib/libQt5Widgets.so.5 0xf7ad5d65
8 QWidgetPrivate::show_sys() /usr/local/Qt32/5.3/gcc/lib/libQt5Widgets.so.5 0xf7ad60b6
9 QWidgetPrivate::show_helper() /usr/local/Qt32/5.3/gcc/lib/libQt5Widgets.so.5 0xf7abab35
10 QWidget::setVisible(bool) /usr/local/Qt32/5.3/gcc/lib/libQt5Widgets.so.5 0xf7abb005
11 QWidget::show() /usr/local/Qt32/5.3/gcc/lib/libQt5Widgets.so.5 0xf7aad77e
12 main main.cpp 17 0x804a21f
我尝试按如下方式加载资源:
QLabel *mainLabel = new QLabel;
mainLabel->setPixmap(pix);
mainLabel->show();
这没有问题。任何帮助是极大的赞赏。 Ubuntu 14.04 x64,编译32位,Qt 5.3
更新:我重新安装了ubuntu-desktop(我将桌面从32位恢复到64位)现在我收到错误:
The X11 connection broke: Maximum allowed requested length exceeded (code 4)
XIO: fatal IO error 2 (No such file or directory) on X server ":0"
after 409 requests (409 known processed) with 0 events remaining.
答案 0 :(得分:3)
我也遇到过这个。原因是图标太大。调整大小,例如256x256。