Unsolved Disable the mouse event when a button is pressed
-
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 ?
-
Hi
Disable mouseEvent for what widget? -
@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.
-
@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. -
@mrjj ya but i want to in the manner which i have specified , is there any other way i can acheive this ?
-
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();
-
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 -
@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.