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:

    Drawers.pro
    @
    QT += core gui

    TARGET = Drawers
    TEMPLATE = app

    SOURCES += main.cpp
    mainwindow.cpp

    HEADERS += mainwindow.h
    @

    mainwindow.h
    @
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QMainWindow>

    class MainWindow : public QMainWindow
    {
    Q_OBJECT

    public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow(){};
    };

    #endif // MAINWINDOW_H
    @

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

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent)
    {
    QToolBar *toolBar=addToolBar("ToolBar");
    QAction *action=new QAction("Action", this);
    action->setCheckable(true);
    action->setShortcut(Qt::Key_E);
    toolBar->addAction(action);

    // 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);
    

    }
    @

    main.cpp
    @
    #include <QtGui/QApplication>
    #include "mainwindow.h"

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

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

    }
    @

    All help and/or suggestions greatly appreciated :o)


  • Lifetime Qt Champion

    Hi,

    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":https://bugreports.qt-project.org/browse/QTBUG-26282

    I'd recommend re-opening it with your findings


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.