Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-15746

QKeySequence::PreviousChild not working

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 4.7.1
    • Core: Event loop
    • None
    • Windows

    Description

      QKeySequence::PreviousChild does not work when set as a shortcut for navigating between tabs in a QTabWidget. When having the following code for navigating to the nextChild:

      connect(actionNext, SIGNAL(triggered()), this, SLOT(nextTabPageTriggered()));
      actionNext->setShortcut(QKeySequence::NextChild);

      and the following code for navigating to the previous child:
      connect(actionPrevious, SIGNAL(triggered()), this, SLOT(prevTabPageTriggered()));
      actionPrevious->setShortcut(QKeySequence::PreviousChild);

      then QKeySequence::NextChild is catched in the slot, but KeySequence::PreviousChild never gets called.

      The following example demonstrates the problem:

      #include <QtGui>
      
      class TabWidget : public QTabWidget
      {
      	Q_OBJECT
      public:
      	TabWidget()
      	{
      		firstTab = new QWidget(this);
      		secondTab = new QWidget(this);
      
      		addTab(firstTab, "First Tab");
      		addTab(secondTab, "Second Tab");
      
      		secondAction = new QAction(this);
      		secondAction->setShortcut(QKeySequence::PreviousChild);
      
      
      		QAction *firstAction = new QAction(this);
      		firstAction->setShortcut(QKeySequence::NextChild);
      
      		addAction(secondAction);
      		addAction(firstAction);
      
      		connect(firstAction, SIGNAL(triggered(bool)), this, SLOT(nextTabPageTriggered()));
      		connect(secondAction, SIGNAL(triggered(bool)), this, SLOT(previousTabPageTriggered()));
      	}
      
      	public slots:
      		void nextTabPageTriggered()
      		{
      			qDebug() << "NEXT";
      		}
      
      		void previousTabPageTriggered()
      		{
      			qDebug() << "PREVIOUS";
      		}
      
      private:
      	QWidget *firstTab;
      	QWidget *secondTab;
      	QAction *secondAction;
      };
      
      #include "main.moc"
      
      int main(int argc, char** argv)
      {
      	QApplication app(argc, argv);
      	TabWidget window;
      	window.show();
      	return app.exec();
      
      }

      Attachments

        For Gerrit Dashboard: QTBUG-15746
        # Subject Branch Project Status CR V

        Activity

          People

            Unassigned Unassigned
            naevdal Sigrid Fjell Nævdal (Inactive)
            Votes:
            10 Vote for this issue
            Watchers:
            12 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There is 1 open Gerrit change