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 not working as expected with 3rd paramaeter(GUIMode)
Forum Updated to NodeBB v4.3 + New Features

QApplication not working as expected with 3rd paramaeter(GUIMode)

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 6 Posters 2.0k 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.
  • seetharamS Offline
    seetharamS Offline
    seetharam
    wrote on last edited by
    #1

    Hi ,

    I have used QApplication (argc, argv, bool GUIMode ) to run application in non gui mode. With this functionality I could run my application in command mode without connecting to Xserver.
    Now I have installed Qt 5.6 in my machine and , I am not able to run application in command mode , Apllication is getting crashed with below error.
    QXcbConnection: Could not connect to display

    Could you please let me know , if you have any idea , how to run QT application in non gui mode without using X server.

    With QCoreApplication I can solve this problem but , my application should support both GUI and commnad mode.
    Kindly Help me to resolve this issue.

    Thansks in advance
    Seetharam

    jsulmJ 1 Reply Last reply
    0
    • seetharamS seetharam

      Hi ,

      I have used QApplication (argc, argv, bool GUIMode ) to run application in non gui mode. With this functionality I could run my application in command mode without connecting to Xserver.
      Now I have installed Qt 5.6 in my machine and , I am not able to run application in command mode , Apllication is getting crashed with below error.
      QXcbConnection: Could not connect to display

      Could you please let me know , if you have any idea , how to run QT application in non gui mode without using X server.

      With QCoreApplication I can solve this problem but , my application should support both GUI and commnad mode.
      Kindly Help me to resolve this issue.

      Thansks in advance
      Seetharam

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

      @seetharam QApplication does not have a constructor with 3 parameters: http://doc.qt.io/qt-5/qapplication.html#QApplication
      Do you use a modified Qt version? Your own QApplication class?

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

      1 Reply Last reply
      1
      • seetharamS Offline
        seetharamS Offline
        seetharam
        wrote on last edited by
        #3

        Yes , in QT 5.6 it is not available .

        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4
          #include <memory>
          int main(int argc, char **argv)
          {
          bool useGui = false;
          std::unique_ptr<QCoreApplication> pApp(nullptr);
          if(useGui)
          pApp.reset(new QApplication(argc,argv));
          else
          pApp.reset(new QCoreApplication(argc,argv));
          
          return  pApp->exec();
          }

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          6
          • seetharamS Offline
            seetharamS Offline
            seetharam
            wrote on last edited by
            #5

            @seetharam in Qt5 .6 version of QT , we do not have the QApplication constructor with third paramter to disbale GUI mode.
            Hi VRonin,
            Thanks for reply.
            but actually , my application is implemented in a differnet way .

            I am using class which is inherited from QApplication . I have passed false to third argument for non gui mode.
            now as per QT 5.6 , I could see only a way that I need to duplicate the class which need to be inheriited from QCore Application.

            before:
            class myClass : public AQpplciation
            {
            };

            Now it should be like
            class myguiclass : public QApplication
            {
            };
            class myclass : public QCoreApplication
            {
            };

            Is there any other way instead of writing two separate classes for QApplication and QCore application?

            Regards,
            Seetharam

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

              Hi,

              Out of curiosity, why did you need to subclass QApplication ?

              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
              1
              • seetharamS Offline
                seetharamS Offline
                seetharam
                wrote on last edited by
                #7

                Hi SGaist,
                Thanks for the reply.
                In my application I am inheriting a class from QApplication and initially I will show a logo in a separate thread and then close that logo after my application is launched and also I am doing many other configurations which are related to my application.
                To do these things I need to inherite a class from QApplication.
                To make it work for console mode I did guimode false in QApplication constructor before .
                but it is not working for me in QT 5.6

                Regards,
                Seetharam

                JonBJ 1 Reply Last reply
                0
                • seetharamS seetharam

                  Hi SGaist,
                  Thanks for the reply.
                  In my application I am inheriting a class from QApplication and initially I will show a logo in a separate thread and then close that logo after my application is launched and also I am doing many other configurations which are related to my application.
                  To do these things I need to inherite a class from QApplication.
                  To make it work for console mode I did guimode false in QApplication constructor before .
                  but it is not working for me in QT 5.6

                  Regards,
                  Seetharam

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by
                  #8

                  @seetharam
                  I see this is the 3rd identical post for this question. So I have wasted my time posting a solution in one of the others... :@ Please just don't!

                  1 Reply Last reply
                  1
                  • M Offline
                    M Offline
                    Maddineni
                    wrote on last edited by
                    #9

                    Hi , Sorry for the inconvienience .
                    I could not delete the duplicate posts.
                    Could you please delete duplicates except the the post in which the query was answered? Answered one is locked I guess.

                    Thanks in advance.
                    Seetharam

                    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