⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)

How to set tabfocus on radiobuttons in two columns

  • 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




    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"));



    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.

  • Lifetime Qt Champion


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

  • 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.

  • Lifetime Qt Champion

    Did you run it through a debugger ?

Log in to reply