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. Invoking the window "Help Window" from command line
Forum Update on Monday, May 27th 2025

Invoking the window "Help Window" from command line

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 1.7k 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.
  • A Offline
    A Offline
    anuj nogja
    wrote on last edited by
    #1

    Hello All,
    In my project, I have created a "Help" button in MainWindow. When this button is clicked, a new window is opened and help related content is available in this window. It is working fine.

    The requirement is when user enters " ./<project-name> -h" from command line then that only help window should get invoked (main window where other project stuff is also present should not get invoked) so that user can see help page.

    Kindly suggest the approach...
    Thanks..

    Regards,
    Anuj

    jsulmJ 1 Reply Last reply
    0
    • A anuj nogja

      Hello All,
      In my project, I have created a "Help" button in MainWindow. When this button is clicked, a new window is opened and help related content is available in this window. It is working fine.

      The requirement is when user enters " ./<project-name> -h" from command line then that only help window should get invoked (main window where other project stuff is also present should not get invoked) so that user can see help page.

      Kindly suggest the approach...
      Thanks..

      Regards,
      Anuj

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

      @anuj-nogja said in Invoking the window "Help Window" from command line:

      ./<project-name> -h

      Sounds like an unusual approach.
      Usually "./<project-name> -h" shows help in the terminal not in a window.
      But if you really want to implement it this way then simply check command line parameters and if -h is passed you do not create your main window but only this help window.

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

      A 1 Reply Last reply
      2
      • jsulmJ jsulm

        @anuj-nogja said in Invoking the window "Help Window" from command line:

        ./<project-name> -h

        Sounds like an unusual approach.
        Usually "./<project-name> -h" shows help in the terminal not in a window.
        But if you really want to implement it this way then simply check command line parameters and if -h is passed you do not create your main window but only this help window.

        A Offline
        A Offline
        anuj nogja
        wrote on last edited by anuj nogja
        #3

        @jsulm Hi,
        While calling help window as -h condition is true, help window is not getting displayed. (Its going in some infinite loop).
        Code i have written is:
        if((argc==2) && (strcmp(argv[1],"-h")==0))
        {
        HelpWindow help;
        help.show()
        }

        Kindly suggest..

        jsulmJ 2 Replies Last reply
        0
        • A anuj nogja

          @jsulm Hi,
          While calling help window as -h condition is true, help window is not getting displayed. (Its going in some infinite loop).
          Code i have written is:
          if((argc==2) && (strcmp(argv[1],"-h")==0))
          {
          HelpWindow help;
          help.show()
          }

          Kindly suggest..

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

          @anuj-nogja Please show whole content of your main()

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

          1 Reply Last reply
          0
          • A anuj nogja

            @jsulm Hi,
            While calling help window as -h condition is true, help window is not getting displayed. (Its going in some infinite loop).
            Code i have written is:
            if((argc==2) && (strcmp(argv[1],"-h")==0))
            {
            HelpWindow help;
            help.show()
            }

            Kindly suggest..

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

            @anuj-nogja As @J-Hilk pointeg out here https://forum.qt.io/topic/87579/window-not-invoking-not-displaying-when-called-from-inside-if-block/3 you're creating the window instances inside if {} else {} blocks. That means as soon es if {} or else {} block is left your windows are destroyed.

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

            JonBJ 1 Reply Last reply
            1
            • jsulmJ jsulm

              @anuj-nogja As @J-Hilk pointeg out here https://forum.qt.io/topic/87579/window-not-invoking-not-displaying-when-called-from-inside-if-block/3 you're creating the window instances inside if {} else {} blocks. That means as soon es if {} or else {} block is left your windows are destroyed.

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

              @anuj-nogja
              If help were a QDialog, you could also go help.exec() instead of help.show() and your code would work as-is.

              @jsulm
              I'd like to understand one thing about this commonly-reported problem posters have, bearing in mind that I use Python not C++ so I do not encounter stack variable/out of scope.

              When he goes help.show(), "in principle" that shows the window (though I do understand there is probably delay till message loop gets pumped).

              When his code then hits the } close scope, that destructs help. Do I presume that if a shown window/dialog is destructed, Qt does an implicit "hide"/"close" on it first?

              jsulmJ 1 Reply Last reply
              0
              • JonBJ JonB

                @anuj-nogja
                If help were a QDialog, you could also go help.exec() instead of help.show() and your code would work as-is.

                @jsulm
                I'd like to understand one thing about this commonly-reported problem posters have, bearing in mind that I use Python not C++ so I do not encounter stack variable/out of scope.

                When he goes help.show(), "in principle" that shows the window (though I do understand there is probably delay till message loop gets pumped).

                When his code then hits the } close scope, that destructs help. Do I presume that if a shown window/dialog is destructed, Qt does an implicit "hide"/"close" on it first?

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

                @JonB I don't know whether Qt does a hide first or simply removes the window. I'm not even sure whether the dialog is shown at all in this case as show() is asynchronous/non blocking and the dialog is destroyed just after calling show().

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

                JonBJ 1 Reply Last reply
                1
                • jsulmJ jsulm

                  @JonB I don't know whether Qt does a hide first or simply removes the window. I'm not even sure whether the dialog is shown at all in this case as show() is asynchronous/non blocking and the dialog is destroyed just after calling show().

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

                  @jsulm
                  Yep, OK. I sort of expected the code to "crash" in the message loop pump, in that there would be a pending message to "show that window" but when processed asynchronously Qt would find no such window in existence. I guess it just ignores a message for a window which does not exist....

                  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