Running a Qt Application at Startup

Run application on startup

For everybody who are trying to solve the problem, this is the 100% working solution:

How can I ask the user for elevated permissions at runtime?

  1. create app1.exe
  2. create app2.exe with admin priveleges - tutorial is in the first post (manifest file, mt.exe, etc..)
  3. when user tick the checkbox in app1.exe, i call the the app2.exe (for example with no arguments) - you can find all function for this @ the link ive just posted above
    // well, in fact, you dont have to use the function from the example above:
    i find this call much better

                  QObject *parent = new QObject();
    QString program = AppToExec; //"/path/to/the/app2.exe"
    QStringList arguments ;
    arguments << ""; //just in case we want arguments
    QProcess *myProcess = new QProcess(parent);
    myProcess->start(program);
  4. app2.exe, for example

      QApplication a(argc, argv);
    MainWindow w;
    // w.show();
    if (argc == 1) {
    w.test();
    a.quit();

    }
  5. problem solved.

How to run a Qt application run at startup?

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

Running a Qt application at startup

You need to create a desktop entry file for your application (see here) and to put it in user's $HOME/.config/autostart directory.

Any desktop entry file in that dir will get executed when a Window Manager starts up (see here).

To do this, usually you'll need to create your desktop entry file by hand (that's it, not via C++ code/script) and to just install in that directory via C++ code.

Start Qt app right after initial windows startup

It is not possible to customize the Windows graphical identification and authentication (GINA) using only Qt. GINA is a component of some Microsoft Windows operating systems that provides secure authentication and interactive logon services. You will have to implement a custom GINA, which involves providing implementation for a set of native API calls. More information on this topic is available at Wikipedia.

Qt C++ application: self autostart installation in Linux

You can add application in various ways.

  1. Via linux init system. For newest linux OS systemd is a standard. In this case your need to create systemd unit for your application
  2. Via desktop manager, such as gnome, kde and possible others. In this case you need also create specification for autostarting your app.
  3. Via bash files

I think, prefered way via systemd unit, because now this is standard way for starting process at boot time and for special user, if need.

How to hide QMainWindow and show splashcreen during startup?

Based on your code and some example I could make it run like you are trying to do.
You only need to call your promptLogin function instead.


#include <QApplication>
#include <QTimer>
#include <QSplashScreen>
#include "mainwindow.h"

int main(int argc, char *argv[])
{
QApplication app(argc, argv);

QSplashScreen *splash = new QSplashScreen;
splash->setPixmap(QPixmap("D:\\Projects\\SplashScreen\\TestSplashScreen\\splash.png"));
splash->show();

MainWindow mainWin;

QTimer::singleShot(2500, splash, SLOT(close()));
QTimer::singleShot(2500, &mainWin, SLOT(show()));

return app.exec();
}



Related Topics



Leave a reply



Submit