Give focus to QGraphicsView without stealing focus from Qbutton
-
I have sidebar which have multiple Qbutton to switch between pages of a stackedwidget to let the user know which page they are in based on button clicked, i am using stylesheet Qbutton:focus but i also have custom QGraphicsView and handling keypressevent and the problem is clicking on QGraphicsView steals the focus from button what can be the solution ?
Snippet how my code look :
Qbutton:focus { background-color:rgb(40,40,40) }
class cutomView : public QGraphicsView { public: // etc protected: void KeyPressEvent(QKeyEvent *event) override; }
-
Add all of your buttons which control the stackedWidget to a
QButtonGroup
and make it exklusive withsetExclusive
-
@Narutoblaze
try:
QPushButton:checked{ background-color: rgb(40,40,40) -
Add all of your buttons which control the stackedWidget to a
QButtonGroup
and make it exklusive withsetExclusive
-
@Narutoblaze
You have to call setAutoExclusive(true)
for all the buttons. -
-
-