How to run a Qt application run at startup? [duplicate]

﹥>﹥吖頭↗ 提交于 2019-12-24 06:38:04

问题


Possible Duplicate:
running a qt application at startup

How can I run a qt program at startup so that the user won't see the desktop at all? I am building my program in linux and I want to distribute it to linux users. I want to add that code to my app, because the customers don't have any understanding about linux. I found that QSettings can do that, is it true? What about QService? Can we use a simple code like this?

QSettings  a;
A.setpath(IniFormat,SystemScope,/etc/xdg)

回答1:


QSettings has zero relevance to this and QService is for Symbian devices. In fact, your question has nothing to do with Qt.

What you need to do is place a *.desktop shortcut or link to the application in the user's startup folder. See:

http://standards.freedesktop.org/autostart-spec/autostart-spec-latest.html.

For example, if I want to start the application /opt/myapp/myapp_executable at login, I would create a myapp.desktop file with the following contents:

[Desktop Entry]
Exec=/opt/myapp/myapp_executable

and put it in my ~/.config/autostart directory.

If you want it to be executed for every user at login, then you'd put it in /etc/xdg/autostart/. But again, check the XDG site because the directory can be different if an XDG environment variable is set that overrides the default.

Your question really belongs on http://superuser.com




回答2:


If you are using linux, use cron to launch your program, add something like this to crontab:

@reboot /path/to/program

Or to launch it at user login, append /path/to/program to ~/.bashrc or ~/.bash_profile



来源:https://stackoverflow.com/questions/14030932/how-to-run-a-qt-application-run-at-startup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!