Unsolved QPushButton is automatically selected (highlighted) when opening GUI
-
Hey,
I have created a GUI in Qt on Linux and when I open it, there is always one QPushButton selected. When I use arrow keys I can switch between all my buttons. How can I disable the auto-selection of one button?
I already tried this in my MainWindow.cpp but it doesn't change anything.
QWidget::setFocusPolicy(Qt::NoFocus);
Does anyone have an idea?
Thanks!
-
@Beatsteak Try setting autoDefault and default to false or whatever relevant.
-
Go to design in the qt creator and when your window shows go to Edit Tab Order. This option is on the bar under the file, edit,build etc. There you can change the order number of your button.
Another solution is to set focus policy to nofocus. -
said in QPushButton is automatically selected (highlighted) when opening GUI:
Does anyone have an idea?
Qt finds the first focus able widget.
ReimplementQWidget::focusNextPrev()
(by simply returning true) for the top most widget (MainWindow/central widget).