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. How to set default focus for a Dialog
Qt 6.11 is out! See what's new in the release blog

How to set default focus for a Dialog

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 1.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.
  • M Offline
    M Offline
    MasterBlade
    wrote on last edited by
    #1

    Hello I have a dialog that requires users to input a value to a spinbox.

    Is it possible to set focus to the spinbox so that users can type numbers to it immediately?

    jsulmJ Taz742T 2 Replies Last reply
    0
    • M MasterBlade

      Hello I have a dialog that requires users to input a value to a spinbox.

      Is it possible to set focus to the spinbox so that users can type numbers to it immediately?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @MasterBlade See http://doc.qt.io/qt-5/qwidget.html#setTabOrder and http://doc.qt.io/qt-5/focus.html

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M MasterBlade

        Hello I have a dialog that requires users to input a value to a spinbox.

        Is it possible to set focus to the spinbox so that users can type numbers to it immediately?

        Taz742T Offline
        Taz742T Offline
        Taz742
        wrote on last edited by Taz742
        #3

        @MasterBlade
        In your constructor try this:

            ui->spinBox->clear();
            QTimer::singleShot(200, ui->spinBox, SLOT(setFocus()));
        

        Do what you want.

        M 1 Reply Last reply
        1
        • Taz742T Taz742

          @MasterBlade
          In your constructor try this:

              ui->spinBox->clear();
              QTimer::singleShot(200, ui->spinBox, SLOT(setFocus()));
          
          M Offline
          M Offline
          MasterBlade
          wrote on last edited by
          #4

          @Taz742 said in How to set default focus for a Dialog:

          @MasterBlade
          In your constructor try this:

              ui->spinBox->clear();
              QTimer::singleShot(200, ui->spinBox, SLOT(setFocus()));
          

          Thanks for the help!

          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