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 can we trasfer widget focus to next widget by pressing tab key?
Forum Updated to NodeBB v4.3 + New Features

How can we trasfer widget focus to next widget by pressing tab key?

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 5.7k 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.
  • P Offline
    P Offline
    pratik041
    wrote on last edited by
    #1

    I have multiple widget. I was trying the function @setTabOrder()@ but it was not working . I don't know where i was wrong in that.

    Pratik Agrawal

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Rahul Das
      wrote on last edited by
      #2

      http://developer.qt.nokia.com/doc/qt-4.8/qwidget.html#setTabOrder

      According to the Doc :
      @ // WRONG
      setTabOrder(c, d); // c to d
      setTabOrder(a, b); // a to b AND c to d
      setTabOrder(b, c); // a to b to c, but not c to d
      @

      Check your codes


      Declaration of (Platform) independence.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        pratik041
        wrote on last edited by
        #3

        [quote author="Rahul Das" date="1324882460"]http://developer.qt.nokia.com/doc/qt-4.8/qwidget.html#setTabOrder

        According to the Doc :
        @ // WRONG
        setTabOrder(c, d); // c to d
        setTabOrder(a, b); // a to b AND c to d
        setTabOrder(b, c); // a to b to c, but not c to d
        @

        Check your codes[/quote]
        I have tried something like this but not getting focus
        @
        int main(int argc, char *argv[])
        {
        QApplication a(argc, argv);
        MainWindow w;
        QRadioButton *radio1 = new QRadioButton("radiobutton1",&w);
        radio1->setGeometry (150,20,100,40);
        QRadioButton *radio2 = new QRadioButton("radiobutton2",&w);
        radio2->setGeometry (200,50,100,40);
        QRadioButton *radio3 = new QRadioButton("radiobuton3",&w);
        radio3->setGeometry (240,80,100,40);
        QWidget::setTabOrder (radio1,radio2);
        QWidget::setTabOrder (radio2,radio3);
        w.show();
        return a.exec();
        }
        @

        Pratik Agrawal

        1 Reply Last reply
        0
        • R Offline
          R Offline
          Rahul Das
          wrote on last edited by
          #4

          code looks ok to me. Tried using up/down arrow keys? Is it working ?


          Declaration of (Platform) independence.

          1 Reply Last reply
          0
          • R Offline
            R Offline
            Rahul Das
            wrote on last edited by
            #5

            Just remembered... Here the problem must be autoExclussive property.

            Just set it false :

            @
            radio1->setAutoExclusive(0);
            radio2->setAutoExclusive(0);
            radio3->setAutoExclusive(0);@

            Let me know the result.


            Declaration of (Platform) independence.

            1 Reply Last reply
            0
            • P Offline
              P Offline
              pratik041
              wrote on last edited by
              #6

              [quote author="Rahul Das" date="1324886219"]Just remembered... Here the problem must be autoExclussive property.

              Just set it false :

              @
              radio1->setAutoExclusive(0);
              radio2->setAutoExclusive(0);
              radio3->setAutoExclusive(0);@

              Let me know the result.[/quote]

              Thanks, now it is working but i have one more doubt here suppose i have custom widget there how i can show visually that the focus is in that widget.

              Pratik Agrawal

              1 Reply Last reply
              0
              • R Offline
                R Offline
                Rahul Das
                wrote on last edited by
                #7

                There could be many ways. If your custom widget contain radio,lineedit etc, and you want to focus one emong them, you may use QWidget::setFocusProxy.

                Or if any visual changes in appearance is needed on focus, you can reimplement QWidget::focusInEvent and set some styles.

                You can use event filters also.


                Declaration of (Platform) independence.

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goetz
                  wrote on last edited by
                  #8

                  The style in charge usually handles this. The widget having the focus is most often displayed differently. If not, then this is the usual behavior of that style and you should mess with that only for very good reasons - which most developers do not have, to be honest.

                  http://www.catb.org/~esr/faqs/smart-questions.html

                  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