1

Is it possible to add some widgets to a QTabBar? I wanted to have a QComboBox to the side of the last tab, and have it only appear when the last tab is selected.

2 Answers 2

1

It's possible to add child overlay widgets to any widget, so the answer is: sure!

You can hook to the tab widgets's or tab bar's signals to get notified when the last tab is selected. Then use tabRect() to get the rectangle of the last tab. Position your combo box to the right of it. It'd need to be a child of the tab bar. That's it.

16
  • Is it possible to do it in Qt Designer? Jan 23, 2014 at 21:52
  • @mFeinstein: No, you have to write some code for this. In the long run I find Qt Designer to be a hindrance more than help. It confuses the heck out of newbies who don't realize that widgets can be easily composed programmatically. Jan 23, 2014 at 21:53
  • @mFeinstein Anyway, to use your widget you have to write some code anyway, so Qt Designer not letting you do it is of no consequence. Jan 23, 2014 at 21:54
  • Yes, I just wanted to speed things up..one thing I find annoying in Qt Designer (probably Qt in general) is to deal with layouts, the form editor of visual studio makes stuff a lot easier with ancors and aligments... Jan 23, 2014 at 21:57
  • @mFeinstein QML has it all. Jan 23, 2014 at 22:12
-1

It might be easier to use a QStackedWidget to get your desired results. When you are using the QStackedWidget you can have different buttons outside that reveal the different widgets. Then use some custom signal for when the last button is activated to show a combobox that appears next to the last button.

Here is the link to the QStackedWidget

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.