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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:49:23+00:00 2026-06-13T09:49:23+00:00

I have a QMainWindow with a menu bar, including menu items for Save, Open

  • 0

I have a QMainWindow with a menu bar, including menu items for Save, Open and Quit with the usual shortcuts. It creates a QTableWidget that lists a bunch of different categories from which the user can choose (at his option).

If the user clicks into the QTableWidget to change categories, the widget takes the focus. That’s mostly what I want, but unfortunately it also seems to steal the menu shortcuts, so that pressing Ctrl+S no longer triggers the save.

I experimented with keyPressEvent to solve this, but it seems like overkill even if I do get it working. Isn’t there a way to delegate all the control/menu keys back to the QMainWindow ?

  • 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-13T09:49:24+00:00Added an answer on June 13, 2026 at 9:49 am

    There must be an issue with how you are creating your QMenuBar. Here is an example that works just fine for me. The Save continues to function regardless of focus being in the table:

    class Window(QtGui.QMainWindow):
    
        def __init__(self):
            super(Window, self).__init__()
            self.resize(640,480)
    
            menuBar = self.menuBar()
            menu = menuBar.addMenu("&File")
            action = menu.addAction("&Save", self.doAction)
            action.setShortcuts(QtGui.QKeySequence.Save)
    
            self.view = QtGui.QTableWidget(5,5)
            self.setCentralWidget(self.view)
    
        def doAction(self):
            print "Save"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to have a QMainWindow that can change it's look at runtime,
I have a class that inherits QMainWindow and I just want it to have
I have a window that has a menu, a toolbar at the top, and
I have in my main window 2 triggers 1. from the menu that closed
I have a QMainWindow that has a QWidget . The QWidget appears, and has
I have a Qt application with a system tray icon and a menu that
i have a QMainWindow. It has this parameters: this->setWindowFlags(Qt::Tool); this->setFocusPolicy(Qt::StrongFocus); this->setAttribute(Qt::WA_QuitOnClose,true); After showEvent calles
I have a QMainWindow which spawns a few wizards. The QMainWindow has a QFrame
I have an inactive QMainWindow with a QTabWidget as CentralWidget which holds multiple QPlainTextEdits
I have a widget class subclass of QMainWindow, and it has a central widget(QWidget),

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.