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 tabfocus on radiobuttons in two columns
Forum Updated to NodeBB v4.3 + New Features

How to set tabfocus on radiobuttons in two columns

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 810 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.
  • R Offline
    R Offline
    roseicollis
    wrote on last edited by
    #1

    Hi!

    I'm making an app with keyboard interaction so all the logic between widgets its throw TabFocus. I found a problem when I tried to put 4 radiobuttons and see that you have to use arrows instead of tab and spacebar so searching a little bit I found this example about how to do it with tab: "EXAMPLE":http://www.qtcentre.org/wiki/index.php?title=Button_groups_with_tab_focus

    I added this new class "CustomButtonGroup" and applied it BUT I have another problem which is: I have 4 radiobuttons and I need them to be in 2 different columns (qrb_1 and qrb_2 on the left side, and qrb_3 and qrn_4 on the right one). To do that I used some layouts like this:

    • VlayQRB: where I have another widget upside the radiobuttons and then the Hlay2
    • Hlay2: to add 2 vboxlayouts to divide the radiobuttons into 2 columns
    • Vlay2L: for qrb_1 and qrb_2
    • Vlay2R: for qrb_3 and qrb_4

    @
    VlayQRB->addLayout(Hlay2);
    Hlay2->addLayout(Vlay2L);
    Hlay2->addLayout(Vlay2R);

    Vlay2L->addWidget(qrb_1);
    Vlay2L->addWidget(qrb_2);
    Vlay2R->addWidget(qrb_3);
    Vlay2R->addWidget(qrb_4);
    @

    @

    CustomButtonGroup *cBG = new CustomButtonGroup;
    qrb_1 = new QRadioButton(QString::fromUtf8(" Hi 1"));
    qrb_2= new QRadioButton(QString::fromUtf8(" Hi 2"));
    qrb_3 = new QRadioButton(QString::fromUtf8(" Hi 3"));
    qrb_4 = new QRadioButton(QString::fromUtf8(" HI 4"));

    cBG->addButton(qrb_1);
    cBG->addButton(qrb_2);
    cBG->addButton(qrb_3);
    cBG->addButton(qrb_4);

    @

    The problem is that if I do that, the program closes unexpectly when I press space on a radiobutton BUT it works really fine if I only put qrb_1 and qrb_2 so I suppose that the program is becoming crazy with all that logic between so many layouts.

    Any idea of how can I apply the CustomButtonGroup (which gaves me the logic about tab and spacebar I need) to my case (I need 4 radio buttons in 2 colums so I have 2 buttons on the right and 2 buttons on the left)??

    Note: I tried too, creating a second CustomGroupBox and adding there qrb_3 and qrb_4 and it works fine but then, of course, I have 2 options checked on true (one for each custombuttongroup)

    Thank you so much.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Do I understand you right that if you have more than two button in the layout and group it crashes the application ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • R Offline
        R Offline
        roseicollis
        wrote on last edited by
        #3

        Hi Sgaist.

        Yes, but see that they are in 2 diferrent layouts so I think that here is the problem. Btw I've changed the radiobuttons to a combobox while I don't find another soluiton.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Did you run it through a debugger ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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