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

Disable the mouse event when a button is pressed

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 4 Posters 3.4k 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.
  • ManiRonM Offline
    ManiRonM Offline
    ManiRon
    wrote on 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
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Disable mouseEvent for what widget?

      ManiRonM 1 Reply Last reply
      0
      • mrjjM mrjj

        Hi
        Disable mouseEvent for what widget?

        ManiRonM Offline
        ManiRonM Offline
        ManiRon
        wrote on 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.

        mrjjM J.HilkJ 2 Replies Last reply
        0
        • ManiRonM ManiRon

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

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on 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.

          ManiRonM 1 Reply Last reply
          1
          • mrjjM mrjj

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

            ManiRonM Offline
            ManiRonM Offline
            ManiRon
            wrote on 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 ?

            mrjjM 1 Reply Last reply
            0
            • ManiRonM ManiRon

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

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on 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 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
                • ManiRonM ManiRon

                  @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.HilkJ Offline
                  J.HilkJ Offline
                  J.Hilk
                  Moderators
                  wrote on 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

                  • Login

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