Important: Please read the Qt Code of Conduct -

Qt::Drawer blocks QMainWindow keyboard shortcuts

  • Hi All,

    I have an app that constructs a QMainWidow with a QDockWidget configured to be MacOSX drawer widget using the Qt::Drawer window flag. In the QMainWindow I have a QToolBar containing a number of QAction's all of which have keyboard shortcuts associated with them. These shortcuts all work fine until I attach the QDockWidget at which point the actions no longer respond. They can be clicked on, they just don't respond to the keyboard shortcuts. If the QDockWidget is not attached, they work fine. If the QDockWidget is not configured to be a drawer, they work fine. I'm just wondering if anybody else has had this issue and can tell me if I'm doing something wrong or if this is a bug. Either way a solution/work around would be much appreciated.

    The following is a small example illustrating the problem:
    QT += core gui

    TARGET = Drawers
    TEMPLATE = app

    SOURCES += main.cpp

    HEADERS += mainwindow.h

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QMainWindow>

    class MainWindow : public QMainWindow

    explicit MainWindow(QWidget *parent = 0);

    #endif // MAINWINDOW_H

    #include "mainwindow.h"
    #include <QToolBar>
    #include <QAction>
    #include <QDockWidget>

    MainWindow::MainWindow(QWidget *parent) :
    QToolBar *toolBar=addToolBar("ToolBar");
    QAction *action=new QAction("Action", this);

    // Commenting out the following two lines or removing
    // the Qt::Drawer window flag removes the problem
    QDockWidget *dw=new QDockWidget("", this, Qt::Drawer);
    addDockWidget(Qt::LeftDockWidgetArea, dw);


    #include <QtGui/QApplication>
    #include "mainwindow.h"

    int main(int argc, char *argv[])
    QApplication a(argc, argv);
    MainWindow w;;

    return a.exec&#40;&#41;;


    All help and/or suggestions greatly appreciated :o)

  • Lifetime Qt Champion


    Which Qt/OS X combo are you using ?

  • MacOSX 10.8.5 with Qt4.8.

  • Lifetime Qt Champion

    Looks like you are hitting this "bug":

    I'd recommend re-opening it with your findings

Log in to reply