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 in focus when QDialog is loaded

QPushButton is in focus when QDialog is loaded

Scheduled Pinned Locked Moved Unsolved General and Desktop
qpushbuttonfocus
3 Posts 2 Posters 6.6k Views 2 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.
  • G Offline
    G Offline
    gabor53
    wrote on last edited by
    #1

    Hi,
    On the data entry form I set the tab order with the following code:

         LineEdit_Name->setFocus ();
         QWidget::setTabOrder(LineEdit_Name,What_Combo);
         QWidget::setTabOrder (What_Combo,Image_Button);
         QWidget::setTabOrder (Image_Button,Material_Combo);
         QWidget::setTabOrder (Material_Combo,color_Combo);
         QWidget::setTabOrder (color_Combo,descr_TextEdit);
         QWidget::setTabOrder (descr_TextEdit,month_Combo);
         QWidget::setTabOrder (month_Combo,day_Combo);
         QWidget::setTabOrder (day_Combo,year_Combo);
         QWidget::setTabOrder (year_Combo,signedby_Combo);
         QWidget::setTabOrder (signedby_Combo,history_TextEdit);
         QWidget::setTabOrder (history_TextEdit,age_LineEdit);
         QWidget::setTabOrder (age_LineEdit,notes_TextEdit);
         QWidget::setTabOrder (notes_TextEdit,SubmitButton);
    

    Though Image_Button is the third it is always in focus when QDialog is loaded and when Enter is pressed to exit any of the combo boxes Image_Button is triggered. How can I make Image_Button out of focus?
    Thank you.

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      This is due to the autoDefault http://doc.qt.io/qt-5/qpushbutton.html#autoDefault-prop

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      G 1 Reply Last reply
      0
      • VRoninV VRonin

        This is due to the autoDefault http://doc.qt.io/qt-5/qpushbutton.html#autoDefault-prop

        G Offline
        G Offline
        gabor53
        wrote on last edited by
        #3

        @VRonin
        Hi,
        I used

            Image_Button->setAutoDefault (false);
            Image_Button->setDefault (false);
        

        which worked on the Image_Button, but instead the focus shifted on the submit button.
        setDefault() or setAutoDefault() has no effect on submit. How can I make all of the buttons out of focus? Thank you.

        1 Reply Last reply
        1

        • Login

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