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. QPushButton is automatically selected (highlighted) when opening GUI
Forum Updated to NodeBB v4.3 + New Features

QPushButton is automatically selected (highlighted) when opening GUI

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 4.8k 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.
  • BeatsteakB Offline
    BeatsteakB Offline
    Beatsteak
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @Beatsteak Try setting autoDefault and default to false or whatever relevant.

      157

      1 Reply Last reply
      1
      • NickVN Offline
        NickVN Offline
        NickV
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by raven-worx
          #4

          said in QPushButton is automatically selected (highlighted) when opening GUI:

          Does anyone have an idea?

          Qt finds the first focus able widget.
          Reimplement QWidget::focusNextPrev() (by simply returning true) for the top most widget (MainWindow/central widget).

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0

          • Login

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