Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QApplication - exec() in Windows Service
Qt 6.11 is out! See what's new in the release blog

QApplication - exec() in Windows Service

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mr_einsa
    wrote on last edited by
    #1

    Hello,

    i created a Windows Service, without QService... is it possible to add the exec Command?
    I go into the Service, create the Gui ... all done but if i try in my ServiceMain funktion to do a.exec() it fails. Here is some Code:
    @
    QApplication *a;
    int Main(...)
    {
    Gui_class *gc = new Gui_class; //here is the gui createt and it works
    //some connect(); funktions
    //some winService code
    //call ServiceMain(DWORD argc, LPTSTR *argv)
    return 0;
    }

    void WINAPI ServiceMain(DWORD argc, LPTSTR *argv)
    {
    do some stuff
    //start QThread .... it works
    // a->exec();
    while(serviceRun)
    {
    }
    }
    @

    The Problem now is if some signals from the tread comes, the gui didnt execute. But my code is correct because it work without the windows service.

    If i return the a->exec(), in the main funktion it works but only if the service is shutting down...

    Please help me i have to implement the Gui in the service ... is there a way?

    Thank you for your time...

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on last edited by
      #2

      I'm not quite sure if I got your question correctly, but Windows services use a non-interactive window station, thus cannot have a user interface. You will have to use QCoreApplication instead.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved