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. Design pattern for GUI and NON GUI mode.
Forum Updated to NodeBB v4.3 + New Features

Design pattern for GUI and NON GUI mode.

Scheduled Pinned Locked Moved Unsolved General and Desktop
44 Posts 7 Posters 8.4k Views 3 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.
  • A Offline
    A Offline
    Ayush Gupta
    wrote on last edited by
    #14

    @SGaist said in Design pattern for GUI and NON GUI mode.:

    DBus

    What if I need to update the GUI in seperate thread ?

    jsulmJ 1 Reply Last reply
    0
    • A Offline
      A Offline
      Ayush Gupta
      wrote on last edited by Ayush Gupta
      #15

      My GUI and core will be called by other application and it will provided in one dll application.
      So I need to communicate between core and GUI with one dll and update the GUI in seperatee thread,

      Below is the flow which I need to design.

      Application <-----> Get Data <----->
      QT Application ----> Core
      <------>Set Data<-----> -----> Gui ( The data in GUI should be
      updated in seperate thread
      but data should come from
      core)

      1 Reply Last reply
      0
      • A Ayush Gupta

        @SGaist said in Design pattern for GUI and NON GUI mode.:

        DBus

        What if I need to update the GUI in seperate thread ?

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #16

        @Ayush-Gupta said in Design pattern for GUI and NON GUI mode.:

        What if I need to update the GUI in seperate thread ?

        This is not supported!
        If you need to update the UI from other thread then simply emit signals from that thread and update UI in the slots in main thread.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        A 1 Reply Last reply
        0
        • jsulmJ jsulm

          @Ayush-Gupta said in Design pattern for GUI and NON GUI mode.:

          What if I need to update the GUI in seperate thread ?

          This is not supported!
          If you need to update the UI from other thread then simply emit signals from that thread and update UI in the slots in main thread.

          A Offline
          A Offline
          Ayush Gupta
          wrote on last edited by
          #17

          @jsulm Slot will be in GUI part only and signal will emitted from core.
          so should I do event processing in diffrent thread?

          jsulmJ 1 Reply Last reply
          0
          • A Ayush Gupta

            @jsulm Slot will be in GUI part only and signal will emitted from core.
            so should I do event processing in diffrent thread?

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #18

            @Ayush-Gupta said in Design pattern for GUI and NON GUI mode.:

            so should I do event processing in diffrent thread?

            Events are not related to signals/slots

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • A Offline
              A Offline
              Ayush Gupta
              wrote on last edited by
              #19

              There are lot of lag in my system which involved this QT application also.

              I need to reduce lags by creating a headless mode application (without GUI). and also if GUI is launched then it should be updated in a diffrent thread.

              I understand that seperating core and GUI works here. with signal/slots core and GUI can communicate.

              I also know that processEvents() should be called to keep GUI alive if we dont call app->exec(),

              How can I update GUI in seperate thread ? Is the processEvents() is causes lag which I need to call and process in extra thread?

              Or signal/slots are also burder?

              jsulmJ 1 Reply Last reply
              0
              • A Ayush Gupta

                There are lot of lag in my system which involved this QT application also.

                I need to reduce lags by creating a headless mode application (without GUI). and also if GUI is launched then it should be updated in a diffrent thread.

                I understand that seperating core and GUI works here. with signal/slots core and GUI can communicate.

                I also know that processEvents() should be called to keep GUI alive if we dont call app->exec(),

                How can I update GUI in seperate thread ? Is the processEvents() is causes lag which I need to call and process in extra thread?

                Or signal/slots are also burder?

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #20

                @Ayush-Gupta said in Design pattern for GUI and NON GUI mode.:

                How can I update GUI in seperate thread ?

                Again: you do NOT update GUI from another thread as GUI thread! This is simply not supported.
                Your other thread should only tell GUI thread to update.

                "Or signal/slots are also burder?" - in what way?

                "Is the processEvents() is causes lag" - if you're using processEvents then your design is most likely broken. It should not be used. Simply start event loop, this is how Qt applications work.

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                1
                • A Offline
                  A Offline
                  Ayush Gupta
                  wrote on last edited by
                  #21

                  starting event loop means here calling app->exec() ? But it makes the application blocking.

                  jsulmJ 1 Reply Last reply
                  0
                  • A Ayush Gupta

                    starting event loop means here calling app->exec() ? But it makes the application blocking.

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #22

                    @Ayush-Gupta said in Design pattern for GUI and NON GUI mode.:

                    starting event loop means here calling app->exec()

                    No.
                    Please read documentation: https://doc.qt.io/qt-5/qthread.html
                    " QThread object manages one thread of control within the program. QThreads begin executing in run(). By default, run() starts the event loop by calling exec() and runs a Qt event loop inside the thread."

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      Ayush Gupta
                      wrote on last edited by
                      #23

                      Yes I have read this,

                      My QT application launches two forms (main window) then I called app->exec.

                      Then other application use to update data in my QT application using dll interface functions.

                      But if call app->exec() there in no update in GUI.

                      I need to call processEvents() for that

                      jsulmJ 1 Reply Last reply
                      0
                      • A Ayush Gupta

                        Yes I have read this,

                        My QT application launches two forms (main window) then I called app->exec.

                        Then other application use to update data in my QT application using dll interface functions.

                        But if call app->exec() there in no update in GUI.

                        I need to call processEvents() for that

                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by
                        #24

                        @Ayush-Gupta said in Design pattern for GUI and NON GUI mode.:

                        But if call app->exec() there in no update in GUI.

                        Where do you call this? In this DLL?
                        I'm confused a bit with your description.
                        Is this other app a completely different app (other process)?

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          Ayush Gupta
                          wrote on last edited by Ayush Gupta
                          #25

                          Yes other app is different app (Non QT C++ application) which will call my QT application as dll application and will process the data from it and fetch the data using interface applications.

                          jsulmJ 1 Reply Last reply
                          0
                          • A Ayush Gupta

                            Yes other app is different app (Non QT C++ application) which will call my QT application as dll application and will process the data from it and fetch the data using interface applications.

                            jsulmJ Offline
                            jsulmJ Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on last edited by
                            #26

                            @Ayush-Gupta said in Design pattern for GUI and NON GUI mode.:

                            which will call my QT application

                            In this case your Qt application is not an application but a DLL.
                            In this case you can run your DLL in another thread where you call app->exec().
                            But I'm still confused: is this other app a non-gui (console) app? If so why does it load a DLL which opens a GUI?
                            It should be other way around: you have a GUI application (Qt) which uses a DLL. This DLL does the data processing and passes the data from/to Qt application.

                            https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply
                            1
                            • A Offline
                              A Offline
                              Ayush Gupta
                              wrote on last edited by
                              #27

                              Yes other app is non-gui console app.

                              It opens other GUI to show and process the data sended by non-gui console app.

                              But now I have to make my QT (DLL) in both headless mode (non-gui) and GUI mode in same DLL.

                              Actually QT (DLL) is simulator of system and the other non-gui console app sends the data to QT dll app and QT DLL app also send data to non-gui console app

                              1 Reply Last reply
                              0
                              • SGaistS Offline
                                SGaistS Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on last edited by
                                #28

                                Can you describe exactly the architecture of your system ?
                                Because you are sending mixed messages here.
                                At one point you wanted to have an application that you could run either with GUI or not.
                                Now you have a console application that has some sort of DLL interface to drive an application and get fed by another one and one should support two different modes. That make everything unclear.

                                If you could add a drawing of your design, that might also be of great help.

                                Interested in AI ? www.idiap.ch
                                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                1 Reply Last reply
                                2
                                • A Offline
                                  A Offline
                                  Ayush Gupta
                                  wrote on last edited by
                                  #29

                                  Here is some prototype I tried to draw
                                  ProtoType.PNG

                                  1 Reply Last reply
                                  0
                                  • SGaistS Offline
                                    SGaistS Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #30

                                    As I already suggest, you really should consider using IPC rather making your console application drive a GUI application by hand which will make it not a console application. Apply the Unix mantra: one tool that does its job well.

                                    See the various possibilities for inter-process communication. Missing there (fix under way), there's also QLocalServer/Socket.

                                    Interested in AI ? www.idiap.ch
                                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    A 1 Reply Last reply
                                    3
                                    • A Offline
                                      A Offline
                                      Ayush Gupta
                                      wrote on last edited by
                                      #31

                                      @jsulm said in Design pattern for GUI and NON GUI mode.:

                                      But I'm still confused: is this other app a non-gui (console) app? If so why does it load a DLL which opens a GUI?
                                      It should be other way around: you have a GUI application (Qt) which uses a DLL. This DLL does the data processing and passes the data from/to Qt application.

                                      console application I need to keep as it is since it part of system.

                                      I need to work QT application (DLL).
                                      So you mean here two launch core and GUI as two different process and make the code in seperate DLL?

                                      jsulmJ 1 Reply Last reply
                                      0
                                      • A Ayush Gupta

                                        @jsulm said in Design pattern for GUI and NON GUI mode.:

                                        But I'm still confused: is this other app a non-gui (console) app? If so why does it load a DLL which opens a GUI?
                                        It should be other way around: you have a GUI application (Qt) which uses a DLL. This DLL does the data processing and passes the data from/to Qt application.

                                        console application I need to keep as it is since it part of system.

                                        I need to work QT application (DLL).
                                        So you mean here two launch core and GUI as two different process and make the code in seperate DLL?

                                        jsulmJ Offline
                                        jsulmJ Offline
                                        jsulm
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #32

                                        @Ayush-Gupta Yes, starting GUI from console application makes it a GUI application. Look at what @SGaist suggested.

                                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                                        1 Reply Last reply
                                        2
                                        • A Offline
                                          A Offline
                                          Ayush Gupta
                                          wrote on last edited by
                                          #33

                                          sorry it is so confusing for me.

                                          I have to create a QT application (in both GUI and NON-GUI) mode.... and my QT application should be in dll which will launch by other console application.

                                          So means creating two dlls for core and GUI and (core dll should launch) GUI dll ?

                                          and in NON-GUI mode the core dll should not launch GUI dll?

                                          and the commuincation between core dll and GUI dll will be using IPC?

                                          A 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