我开发了一个应用程序(使用 Qt Creator),它使用一些图片作为背景和图标。现在我正在尝试部署它,应用程序已成功安装:
$ make
$ sudo make install
安装目录是/usr/local/ctimer/
,二进制文件位于/usr/local/ctimer/ctimer
。问题是当我执行程序时,例如,使用 Alt + F2/usr/local/ctimer/ctimer
时,图像不会显示。
我注意到,如果我从其文件夹中执行程序一切正常:
$ cd /usr/local/ctimer/
$ ./ctimer
可以使用包含上述命令的 bash 脚本来解决该问题,并将其放入/usr/local/bin/
例如,但我想知道为什么会出现这种行为。
任何想法?
编辑:
这是代码:
void Stopwatch::createMenu()
{
startAction = new QAction(QIcon("pictures/start.png"), tr("&Start/Continue"), this);
startAction->setToolTip("Start/Continue stopwatch");
startAction->setShortcut(Qt::CTRL + Qt::Key_S);
connect(startAction, SIGNAL(triggered()), this, SLOT(start()));
pauseAction = new QAction(QIcon("pictures/pause.png"), tr("&Pause"), this);
pauseAction->setToolTip("Pause stopwatch");
pauseAction->setShortcut(Qt::CTRL + Qt::Key_P);
connect(pauseAction, SIGNAL(triggered()), this, SLOT(pause()));
resetAction = new QAction(QIcon("pictures/reset.png"), tr("&Reset"), this);
resetAction->setToolTip("Reset stopwatch");
resetAction->setShortcut(Qt::CTRL + Qt::Key_C);
connect(resetAction, SIGNAL(triggered()), this, SLOT(reset()));
countDownAction = new QAction(QIcon("pictures/down.png"), tr("&Countdown"), this);
countDownAction->setToolTip("Create a custom count down");
countDownAction->setShortcut(Qt::CTRL + Qt::Key_D);
connect(countDownAction, SIGNAL(triggered()),
countDownDialog, SLOT(show()));
aboutAction = new QAction(QIcon("pictures/about.png"), tr("&About"), this);
aboutAction->setToolTip("About this timer!");
aboutAction->setShortcut(Qt::CTRL + Qt::Key_H);
connect(aboutAction, SIGNAL(triggered()), aboutDialog, SLOT(show()));
quitAction = new QAction(QIcon("pictures/quit.png"), tr("&Quit"), this);
quitAction->setToolTip("Quit timer!");
quitAction->setShortcut(Qt::CTRL + Qt::Key_Q);
connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
contextMenu = new QMenu(this);
contextMenu->addAction(startAction);
contextMenu->addAction(pauseAction);
contextMenu->addAction(resetAction);
contextMenu->addAction(countDownAction);
contextMenu->addAction(aboutAction);
contextMenu->addAction(quitAction);
this->addAction(startAction);
this->addAction(pauseAction);
this->addAction(resetAction);
this->addAction(countDownAction);
this->addAction(aboutAction);
this->addAction(quitAction);
}