Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8425039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:09:57+00:00 2026-06-10T04:09:57+00:00

QActions are great because then can be designed and managed in one place, then

  • 0

QActions are great because then can be designed and managed in one place, then displayed and interfaced with in QMenus, QToolBars, and in theory, any QWidget (every QWidget has an addAction() function, after all). In addition, they are convenient because they can be manipulated in the designer (I need to keep the bulk of my interface in the designer so that people can tweak it).

I’ve run into problems, however :\

What I want to do is simply display some actions (maybe with icons and text, etc) in a group. There are a couple ways I can do this.

  1. Using a QToolBar: This could be perfect because a QToolBar already has a bunch of configuration options (icons, text, both, etc). Unfortunately, I can’t seem to add QToolBars to things other than the the main window (when using the designer). I can do it programmatically, but then then the toolbar must also be populated in code (no good).

  2. Using a regular QWidget: I’ve been trying this for a while with no success at all. Not only am I having problems adding actions to QWidgets in the designer, but even when I add them programmatically I can’t get them to display (I’ve tried setting the contextMenuPolicy to ActionsContextMenu).

Does anyone have any suggestions as to which of these paths might lead to something flexible (useful options to tweak) but also accessible from the designer?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T04:09:58+00:00Added an answer on June 10, 2026 at 4:09 am

    So, the truth of the matter is that the QToolBar class just wasn’t exposed as a widget to designer. Once loaded, you have full access to it. There are 2 relatively simple solutions to your problem – depends on how often you need to do it.

    1: Hack the UI File

    1. If you create a UI file, drag a new, blank QWidget into it.
    2. Save the file out to disk
    3. Open it with a text editor and change the QWidget class to QToolBar
    4. Re-open in designer, you now have a QToolBar in your UI file to work with.

    If you only do this once in a while – this isn’t a bad way to go about it.

    2: Make a QToolBar Designer Plugin

    The slightly longer way to do it (but better if you use this a lot) is to just expose the QToolBar to the Designer yourself. The only thing that is a bit annoying about this tho is that you cannot move it via drag/drop…but whatever, you can still use it and put in layouts and everything.

    I mostly deal with PyQt, so this is what the plugin would look like in PyQt – but you can read through the standard docs for how to do it in C++.

    #!/usr/bin/python
    
    ''' Auto-generated ui widget plugin '''
    
    from PyQt4.QtDesigner import QPyDesignerCustomWidgetPlugin
    from PyQt4.QtGui import QIcon
    from PyQt4.QtGui import QToolBar as WidgetClass
    
    class QToolBarPlugin( QPyDesignerCustomWidgetPlugin ):
        def __init__( self, parent = None ):
            super(QToolBarPlugin, self).__init__( parent )
    
            self.initialized = False
    
        def initialize( self, core ):
            if ( self.initialized ):
                return
    
            self.initialized = True
    
        def isInitialized( self ):
            return self.initialized
    
        def createWidget( self, parent ):
            return WidgetClass(parent)
    
        def name( self ):
            if ( hasattr( WidgetClass, '__designer_name__' ) ):
                return WidgetClass.__designer_name__
            return WidgetClass.__name__
    
        def group( self ):
            if ( hasattr( WidgetClass, '__designer_group__' ) ):
                return WidgetClass.__designer_group__
            return 'ProjexUI'
    
        def icon( self ):
            if ( hasattr( WidgetClass, '__designer_icon__' ) ):
                return QIcon(WidgetClass.__designer_icon__)
            return QIcon()
    
        def toolTip( self ):
            if ( hasattr( WidgetClass, '__designer_tooltip__' ) ):
                return WidgetClass.__designer_tooltip__
            elif ( hasattr( WidgetClass, '__doc__' ) ):
                return str(WidgetClass.__doc__)
            return ''
    
        def whatsThis( self ):
            return ''
    
        def isContainer( self ):
            if ( hasattr( WidgetClass, '__designer_container__' ) ):
                return WidgetClass.__designer_container__
            return False
    
        def includeFile( self ):
            return 'PyQt4.QtGui'
    
        def domXml( self ):
            if ( hasattr( WidgetClass, '__designer_xml__' ) ):
                return WidgetClass.__designer_xml__
    
            return '<widget class="QToolBar" name="toolbar"/>'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On E63 or similar smart phones,there can be three softkeys(the left and right one
I have a widget which can contain one or more QTableView child widgets. By
Is it possible to have a custom icon displayed for a QAction when it
I would like to check to see if there are any keys in $_POST
I have a Qaction on a menu item for deleting selected items in one
This is probably something stupid, but I really can't figure it out myself. I'm
In a Qt application, I have a bunch of automatically-created QActions (menu items) that
Greetings all, In my application,user can open several QWindows which share the same data.(save
I create this object when I want to create a QAction. I then add
I'm trying to create a popup menu, where I can detect the mouse button

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.