Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Start / Kill Qt-GUI - [resolved]
QtWS25 Last Chance

Start / Kill Qt-GUI - [resolved]

Scheduled Pinned Locked Moved Mobile and Embedded
4 Posts 3 Posters 2.5k Views
  • 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.
  • N Offline
    N Offline
    nvharisha
    wrote on last edited by
    #1

    There is requirement of writing a Qt application on a MIPS based platform.

    But there are lots of constraints. The constraints included freeing up of few resources (QGFX Plugin, GPU Memory etc) when there is signal and re-using it later. But the application cannot be killed as its handling lots of other requests and running other things.

    Basically the GUI needs to be killed and free all the resources; later when when required restart again

    One of the way which has been tried is :

    main() -> create a New-Thread

    In the New-Thread,

    @while(<Condition>)
    {
    sem_wait(..)
    m_wnd = new myMainWindow();
    ...
    ..
    app->exec();
    }
    @

    When ever there is a kill command, it comes out of the event loop, and wait for the signal from other threads. Once other threads does the required changes, it will get the signal and will create a new window and goes into the event loop.

    In the main(), there are also few other threads created, which control other devices etc and signal the start and stop for the Qt-GUI.

    The above seems to work but I am not sure if this is the right design. Does it create any problem?

    Can any one suggest any better way?

    Hari

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tobias.hunger
      wrote on last edited by
      #2

      The UI has to be in the main thread, so your approach will not work.

      You are free to delete/create top level widgets like the main window at anytime, so why don't you just delete the UI when no longer needed? By default QApplication will quit when the last window closes, but that can be changed via the "quitOnLastWindowClosed property":http://qt-project.org/doc/qt-4.8/qapplication.html#quitOnLastWindowClosed-prop .

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        Wouldn't it make much more sense to create two applications instead? One application could be your core that actually does the work and responds to outside events, while the GUI could be a separate application that simply connects to this core and that can be killed at time you want.

        1 Reply Last reply
        0
        • N Offline
          N Offline
          nvharisha
          wrote on last edited by
          #4

          Thanks @Tobias, I think i am looking for some thing like this.
          Basically I want to create and destroy the GUI only .

          @Andre - Yes that would have been my choice also. But there are lots of constraints and also, i am not having the liberty to change the existing modules :(.

          EDIT: @Tobias: I was able to get it working with what you have suggested :)

          Hari

          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