Results 1 to 8 of 8

Thread: QAction ToolButton in toolbar triggered should open a TabWidget

  1. #1
    Join Date
    May 2013
    Location
    Schweiz
    Posts
    21
    Thanked 1 Time in 1 Post
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Windows

    Default QAction ToolButton in toolbar triggered should open a TabWidget

    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.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QAction ToolButton in toolbar triggered should open a TabWidget

    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?

  3. #3
    Join Date
    May 2013
    Location
    Schweiz
    Posts
    21
    Thanked 1 Time in 1 Post
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: QAction ToolButton in toolbar triggered should open a TabWidget

    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?

  4. #4
    Join Date
    Sep 2011
    Location
    Bangalore
    Posts
    254
    Thanks
    92
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: QAction ToolButton in toolbar triggered should open a TabWidget

    If you want QTabWidget to be part of QMainWindow, then in mainwindow, do this
    Qt Code:
    1. setCentralWidget(tabWidget);
    To copy to clipboard, switch view to plain text mode 

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

  5. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QAction ToolButton in toolbar triggered should open a TabWidget

    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,
    _

  6. #6
    Join Date
    May 2013
    Location
    Schweiz
    Posts
    21
    Thanked 1 Time in 1 Post
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: QAction ToolButton in toolbar triggered should open a TabWidget

    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?

  7. #7
    Join Date
    May 2013
    Location
    Schweiz
    Posts
    21
    Thanked 1 Time in 1 Post
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: QAction ToolButton in toolbar triggered should open a TabWidget

    hi,

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

  8. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QAction ToolButton in toolbar triggered should open a TabWidget

    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,
    _

Similar Threads

  1. Replies: 3
    Last Post: 10th April 2013, 17:01
  2. QAction, triggered signal dont call a slot
    By kaszewczyk in forum Newbie
    Replies: 6
    Last Post: 5th October 2010, 21:30
  3. Replies: 8
    Last Post: 10th December 2009, 10:06
  4. how exclusive toolbutton in toolbar
    By irmakci in forum Qt Programming
    Replies: 2
    Last Post: 30th July 2008, 22:33
  5. Replies: 2
    Last Post: 27th February 2007, 21:06

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.