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 484321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:17:16+00:00 2026-05-13T01:17:16+00:00

I want to add a submenu in my context menu which is created like

  • 0

I want to add a submenu in my context menu which is created like this:

self.widget_alignment.setContextMenuPolicy(Qt.ActionsContextMenu)

where widget_alignment is QTableWidget.

I created a new QMenu instance:

exchange_bases_menu = QMenu(self.widget_alignment)

added some actions, and I found a method QAction QMenu.addMenu (self, QMenu menu)

but I don’t see any reference to the default context menu for self.widget_alignment.
Additionally, this code:

self.widget_alignment.addMenu(exchange_bases_menu)

gave me: QTableWidget object has no attribute addMenu.

How can I add my submenu to the default context menu?

  • 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-05-13T01:17:16+00:00Added an answer on May 13, 2026 at 1:17 am

    According to the documentation, when a QWidget is set to have the actions context menu type, the widget will construct a context menu based on the list of actions set for the widget. To modify the list of actions, you can call addAction, insertAction, or removeAction. So I would expect you could do something like this (in C++):

    QAction *act_p = new QAction( "Has Submenu", widget_alignment );
    QMenu *submenu_p = new QMenu( act_p );
    // Add items to the submenu
    act_p->setMenu( submenu_p );
    widget_alignment->addAction( act_p );
    

    Without trying it myself, I would expect this to add a “Has Submenu” option to the bottom of the context menu that is generated for the widget, with the submenu you created as the submenu shown.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to add around 9 options to my menu but I would like
I have three level of submenu created dynamically. I want to add class=active where
I'm creating a context menu in code behind with a submenu. I want the
i want to add a submenu to a menu subitem in Joomla 1.7. Example:
I want add my custom sidebar next right column all page. Please check this
I am developing a Excel shared Add-in which has the menu called Custom which
Iv created a basic vertical sliding menu which can be seen here on the
I have a dialog application in which I want to have clickable menu items
i'm working on styling my site's main menu and i would like to add
I have a CSS based menu and I want to add a Slide down

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.