Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Radiobutton near qtabbar



  • hi to every one
    i wrote a program thas has a qtabwidget and radiobutton.
    and the radio button is on top of qtabwidget, i know tabs on qtabwidget create with qtabbar.
    now i want to add my radio buttons on the same row of qtabbar icons,
    how can i do that?
    can you help me?
    !http://up7.iranblog.com/images/1nau7kfo8sc3x4h8rqgz.png(imag)!



  • I suggest next - try using tabbar for parent of radiobutton. If I right widget displayed on top right conner. And You may do inheritor of tabbar with radiobuttons.



  • can you explain more, i cant understand.my english is a little bad
    can you give me a code?



  • My English bad too )), maybe I bad explaining.

    Look:

    "http://zalil.ru/32406713(rb)":http://zalil.ru/32406713(rb)

    If this is something that should be, then code is:

    @ ui->setupUi(this);
    QRadioButton *rb = new QRadioButton (ui->tabWidget);
    rb->setText("SomeText");
    @

    But it is not easy - with second radiobutton You will have trouble. You may placed your radionbutton, for example, in QPanel and it placed on tabbar.

    Maybe better way someone will can offer.



  • thanks alot,now i create this
    but the border comes backward of my radiobuttons widget,how can i make it comes in front of radiobuttons?
    !http://up7.iranblog.com/images/8syy4s9507aj2z1vv0.png(border )!



  • You cannot do that with built-in methods of Qt.

    You have two options, neither one is easy, and both have their drawbacks:

    Use a QTabBar
    Instead of using a QTabWidget, use a [[Doc:QTabBar]]. Put it into a layout together with the readio buttons on top of a [[Doc:QStackedWidget]] or a [[Doc:QStackedLayout]]. You will have to listen to the tab bars signals and select the stack page manually.

    Position the radio buttons manually
    Layout the two radio buttions in a widget. Then position the widget on the top left corner of the tab widget. You will have to listen to resize and move events (probably of the toplevel window your tab is in) in order to reposition the buttions according to the movement of the outer widget.



  • how can i do the second way?
    can you give me some code?



  • i found another way:d
    setmargin to zero and set maximum height a bit lower


Log in to reply