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. How to detect the button press in GUI for optional mode in GUI
Qt 6.11 is out! See what's new in the release blog

How to detect the button press in GUI for optional mode in GUI

Scheduled Pinned Locked Moved Unsolved General and Desktop
15 Posts 4 Posters 1.4k Views 2 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
    #3

    typedef enum
    {
    btn_down,
    btn_up
    }buttonState;

    class ButtonClass
    {
    public:
    ButtonClass();
    void enableButton();
    void disableButton();
    void buttonPresssed();
    void buttonRelease();

    private:
    bool bReleased;
    bool bEnabled;
    buttonState eBtnPos;
    };

    I have this button class while will declare a virtual button if I need to run application with non-gui mode

    when I need to press the button I will call

    ButtonClass test;
    test->enabled();

    When GUI enabled I need to enable the Button in GUI also.

    jsulmJ 1 Reply Last reply
    0
    • A Ayush Gupta

      typedef enum
      {
      btn_down,
      btn_up
      }buttonState;

      class ButtonClass
      {
      public:
      ButtonClass();
      void enableButton();
      void disableButton();
      void buttonPresssed();
      void buttonRelease();

      private:
      bool bReleased;
      bool bEnabled;
      buttonState eBtnPos;
      };

      I have this button class while will declare a virtual button if I need to run application with non-gui mode

      when I need to press the button I will call

      ButtonClass test;
      test->enabled();

      When GUI enabled I need to enable the Button in GUI also.

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

      @Ayush-Gupta Sorry I don't understand...
      What exactly is the problem/question?

      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 Ayush Gupta
        #5

        I have seperated my application in two parts (GUI and Core).

        so that I can run my application in both mode GUI mode and Non-GUI mode.

        I have one form which is having one button (which I will launch in GUI mode of application).

        I have one button as I described above which is in my core part.

        When I tried to do the button press in core part I want that same to be reflected in my GUI part.

        But the reflection in GUI part should be optional.

        Pl45m4P 1 Reply Last reply
        0
        • A Ayush Gupta

          I have seperated my application in two parts (GUI and Core).

          so that I can run my application in both mode GUI mode and Non-GUI mode.

          I have one form which is having one button (which I will launch in GUI mode of application).

          I have one button as I described above which is in my core part.

          When I tried to do the button press in core part I want that same to be reflected in my GUI part.

          But the reflection in GUI part should be optional.

          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote on last edited by Pl45m4
          #6

          @Ayush-Gupta

          Is your ButtonClass even a QPushButton or what kind of class is this?

          So your problem is that you have your virtual button in non-GUI mode, which sets a variable when you trigger it and you dont know how to do this with a "real" pushbutton in GUI mode?!


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

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

            @Pl45m4 My problem is if i press virtual button how It will enable in real button in GUI. (In Gui mode)

            Pl45m4P 1 Reply Last reply
            0
            • A Ayush Gupta

              @Pl45m4 My problem is if i press virtual button how It will enable in real button in GUI. (In Gui mode)

              Pl45m4P Offline
              Pl45m4P Offline
              Pl45m4
              wrote on last edited by
              #8

              @Ayush-Gupta

              Use signals & slots, as @jsulm already said.
              When you click your virtual button, send signal to GUI class and enable / show your GUI Pushbutton.


              If debugging is the process of removing software bugs, then programming must be the process of putting them in.

              ~E. W. Dijkstra

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

                @Pl45m4 But problem is here my core non-virtual button is seperated by GUI.
                And I will not create instance of GUI for non-gui mode.

                jsulmJ 1 Reply Last reply
                0
                • A Ayush Gupta

                  @Pl45m4 But problem is here my core non-virtual button is seperated by GUI.
                  And I will not create instance of GUI for non-gui mode.

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

                  @Ayush-Gupta said in How to detect the button press in GUI for optional mode in GUI:

                  And I will not create instance of GUI for non-gui mode.

                  So what? In this case you do not connect 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
                    #11

                    @jsulm That seems to static compilation than ? Can you give some example?

                    jsulmJ 1 Reply Last reply
                    0
                    • A Ayush Gupta

                      @jsulm That seems to static compilation than ? Can you give some example?

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

                      @Ayush-Gupta What static compilation? What examples? How to connect a signal to a slot?
                      You know when you run with GUI and when without, right? If you run with GUI then connect signal/slot.

                      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
                        #13

                        I am not getting how can I have reference of core (non-virtual button) in GUI so that I can use signal/slot

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

                          how the slot/signal will help if I call virtual button enabled function ? In that I am only setting variable bEnabled ??

                          How can I map the core non- virtual button with real gui button?

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

                            Hi,

                            It seems you have a design issue here. From the looks of it you should rather implement some IPC for your console application which seems to act a bit like a daemon. With that then you can pilot it with your GUI or from somewhere else.

                            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
                            0

                            • Login

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