PDA

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



avpro
15th June 2013, 16:49
hi,

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.

d_stranz
16th June 2013, 02: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?

avpro
16th June 2013, 16: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?

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

setCentralWidget(tabWidget);

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

anda_skoa
16th June 2013, 19: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,

Cheers,
_

avpro
5th September 2013, 22:06
hi,

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?

avpro
7th September 2013, 12:32
hi,

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

anda_skoa
7th September 2013, 13: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?

Cheers,
_