View Full Version : QAction ToolButton in toolbar triggered should open a TabWidget

15th June 2013, 17:49

i checked anything related to this, but no too many posts found; actually nothing relevant.

i have a ToolButton in my toolbar and when is triggered I would like to open a TabWidget. where shall i start?
thanks for your input.

16th June 2013, 03:42
You could start by explaining what you mean by "open a tab widget". Tab widgets don't "open".

Do you mean switching to a specific tab in a tab widget? Creating a new tab widget and displaying it? Something else?

16th June 2013, 17:13
thanks for your prompt reply.

let’s start again: I have my MainWindow, with a Toolbar, on this Toolbar I have a ToolButton. I want to trigger this button and open on a QTabWidget my form, which is a separate .ui file.

when i created the ToolButton, the action was created. What class do I need to initialize to have this QTabWidget opened, if I ‘Go to Slot’ of the created action ?

this QTabWidget I’d like to be part of the MainWindow, not a new window.
how it should be done?

16th June 2013, 17:44
If you want QTabWidget to be part of QMainWindow, then in mainwindow, do this


And if you have multiple tabs, then create a connection to open the particular tab index based on the button click signal.

16th June 2013, 20:13
Since you have an action that is plugged into the toolbar, connect to the action's triggered() signal instead and let the action/toolbar internals handle the button representation,


5th September 2013, 23:06

still wondering how this issue should be approached. i'm back with more details.
let say that my internet browser is my mainWindow.

i have a button/link on my actual page if clicked is opening a new page in a new Tab.

the same I would like to do with my ToolBotton. as soon as i trigger it, the Ui form constructed in a separate .ui file should open in my MainWindow, but in a new Tab.

rawfool wrote
create a connection to open the particular tab index based on the button click signal.

how to do this?

7th September 2013, 13:32

I saw my last reply was not published in the forum list. no idea why? still hoping to receive an answer.

7th September 2013, 14:35
What do you have so far?

Do you have a tab widget as your window's central widget?
Do you have the action in the toolbar?
Do you have a slot connected to the action's triggered() signal?
Do you have the import for the widget you want to show on the new tab?
Does your slot create an instance of that widget?
Does your slot then add the widget to the tab widget?