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 Updated to NodeBB v4.3 + New Features

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 6 Feb 2018, 08:12 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

    J 1 Reply Last reply 6 Feb 2018, 08:25
    0
    • A anuj nogja
      6 Feb 2018, 08:12

      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

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 6 Feb 2018, 08:25 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 8 Feb 2018, 05:31
      2
      • J jsulm
        6 Feb 2018, 08:25

        @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 8 Feb 2018, 05:31 last edited by anuj nogja 2 Aug 2018, 05:32
        #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..

        J 2 Replies Last reply 8 Feb 2018, 05:35
        0
        • A anuj nogja
          8 Feb 2018, 05:31

          @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..

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 8 Feb 2018, 05:35 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
            8 Feb 2018, 05:31

            @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..

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 8 Feb 2018, 07:15 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

            J 1 Reply Last reply 8 Feb 2018, 10:00
            1
            • J jsulm
              8 Feb 2018, 07:15

              @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.

              J Offline
              J Offline
              JonB
              wrote on 8 Feb 2018, 10:00 last edited by JonB 2 Aug 2018, 10:01
              #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?

              J 1 Reply Last reply 8 Feb 2018, 10:05
              0
              • J JonB
                8 Feb 2018, 10:00

                @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?

                J Offline
                J Offline
                jsulm
                Lifetime Qt Champion
                wrote on 8 Feb 2018, 10:05 last edited by jsulm 2 Aug 2018, 10:05
                #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

                J 1 Reply Last reply 8 Feb 2018, 10:15
                1
                • J jsulm
                  8 Feb 2018, 10:05

                  @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().

                  J Offline
                  J Offline
                  JonB
                  wrote on 8 Feb 2018, 10:15 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

                  7/8

                  8 Feb 2018, 10:05

                  • Login

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