[SOLVED] Adding QMenubar under every tab of QTabWidget
I'm trying to find a way to insert a custom menubar for every TAB of QTabWidget. I just could not find any satisfying soulution! Please help me to figure it out.
You can't really add a menu to a tab directly, but there's a workaround. The only assumption is that the content widget of the tab has a layout (no matter what type). Layouts have a
setMenuBar()method so you can sneak the menu there like this:
int numTabs = tabWidget()->count(); for(int i = 0; i < numTabs; ++i) tabWidget->widget(i)->layout()->setMenuBar(yourMenuBar);
@Chris-Kawa omg YES! You are AWESOME! i was cracking my head all day trying to find a solution... Thank you! but Is it possible to realize from QT Designer?
Yeah Chris rocks :)
You cant do it in designer
but you can do it in mainwin constructor after setupIU
it would just be
If you have added it "visually".
@mrjj yeah thats how I'm doing right now, just wanted to know because controlling it from designer would be much comfortable :)
Yeah I agree. But a lot of stuff is not really possible from Designer. Sadly.