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. Disable the mouse event when a button is pressed
Forum Updated to NodeBB v4.3 + New Features

Disable the mouse event when a button is pressed

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 4 Posters 3.6k 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.
  • M Offline
    M Offline
    ManiRon
    wrote on 17 Apr 2019, 10:10 last edited by
    #1

    I want to disable the mouse event when a button is pressed and i have to automatically enable the mouse event when my process is over how can this be done ?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 17 Apr 2019, 10:15 last edited by
      #2

      Hi
      Disable mouseEvent for what widget?

      M 1 Reply Last reply 17 Apr 2019, 10:19
      0
      • M mrjj
        17 Apr 2019, 10:15

        Hi
        Disable mouseEvent for what widget?

        M Offline
        M Offline
        ManiRon
        wrote on 17 Apr 2019, 10:19 last edited by
        #3

        @mrjj Mainwidget . On pressing of a button in Mainwidget should disable mouseevent . My main aim is that instead of disabling each button when another button is pressed . So thought it would be better to disable the mouse event so that user cannot select another button.

        M J 2 Replies Last reply 17 Apr 2019, 10:25
        0
        • M ManiRon
          17 Apr 2019, 10:19

          @mrjj Mainwidget . On pressing of a button in Mainwidget should disable mouseevent . My main aim is that instead of disabling each button when another button is pressed . So thought it would be better to disable the mouse event so that user cannot select another button.

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 17 Apr 2019, 10:25 last edited by
          #4

          @ManiRon
          But mouseEvents are per widget so if there is something in main window
          then user can still click on that.

          Why not just use a dialog?
          if you pop a dialog with exec() ,
          user cannot click anything in mainwin while its open.

          M 1 Reply Last reply 17 Apr 2019, 10:28
          1
          • M mrjj
            17 Apr 2019, 10:25

            @ManiRon
            But mouseEvents are per widget so if there is something in main window
            then user can still click on that.

            Why not just use a dialog?
            if you pop a dialog with exec() ,
            user cannot click anything in mainwin while its open.

            M Offline
            M Offline
            ManiRon
            wrote on 17 Apr 2019, 10:28 last edited by
            #5

            @mrjj ya but i want to in the manner which i have specified , is there any other way i can acheive this ?

            M 1 Reply Last reply 17 Apr 2019, 10:32
            0
            • M ManiRon
              17 Apr 2019, 10:28

              @mrjj ya but i want to in the manner which i have specified , is there any other way i can acheive this ?

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 17 Apr 2019, 10:32 last edited by mrjj
              #6

              @ManiRon

              Well its possible with eventFilter but you have to use it on all widgets in main win.

              Alternative you can put a plain widget on top of it all (transparent) and it will then
              eat all mouse presses.

                  QWidget *blocker = new QWidget(this);
                  blocker->setStyleSheet(QString::fromUtf8("background-color: rgb(61,61, 61,100);")); //just to see it
                  blocker->resize( width(), height());
                  blocker->show();
              
              
              1 Reply Last reply
              2
              • A Offline
                A Offline
                Afflospark
                Banned
                wrote on 17 Apr 2019, 13:51 last edited by
                #7

                Hello,
                As I read You want to use one button at a time or we say when you press a button another buttons are disabled.
                It is possible when you use event filter but you have to use all widgets side by side.
                or you can use
                QWidget *blocker = new QWidget(this);
                blocker->setStyleSheet(QString::fromUtf8("background-color: rgb(61,61, 61,100);")); //just to see it
                blocker->resize( width(), height());
                blocker->show();
                Via this all your mouse click are hide and you can see one press at a time.
                Hope this will help you
                Thanks

                1 Reply Last reply
                0
                • M ManiRon
                  17 Apr 2019, 10:19

                  @mrjj Mainwidget . On pressing of a button in Mainwidget should disable mouseevent . My main aim is that instead of disabling each button when another button is pressed . So thought it would be better to disable the mouse event so that user cannot select another button.

                  J Offline
                  J Offline
                  J.Hilk
                  Moderators
                  wrote on 17 Apr 2019, 13:56 last edited by
                  #8

                  @ManiRon if you have a central parentwidget for all your buttons that are supposed to get disabled, than you can setDisabled on that one and it will automatically propagate the disabled state to all it‘s children.


                  Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                  Q: What's that?
                  A: It's blue light.
                  Q: What does it do?
                  A: It turns blue.

                  1 Reply Last reply
                  2

                  7/8

                  17 Apr 2019, 13:51

                  • 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