[Qt-interest] QTextEdit key bindings

Ryan Oblak rroblak at gmail.com
Mon Jan 26 07:41:08 CET 2009


Hi all,

I'm building a project with Qt 4.4 and need some help with adding a key
binding to QTextEdit.  My central widget is a TabWidget (my QTabWidget
subclass) which contains TextEdit (my QTextEdit subclass).  I would like for
the user to be able to navigate through the tabs by pressing Ctrl+PageUp or
Ctrl+PageDown.  I've set up an action in the TextEdit constructor as
follows:

// set up tab switching action
QAction *nextTabAction = new QAction(this);
nextTabAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_PageDown));
this->connect(nextTabAction, SIGNAL(triggered()), parent, SLOT(nextTab()));

The TabWidget nextTab() slot is as follows:
void TabWidget::nextTab()
{
    if (this->currentIndex() != -1)
    {
        this->setCurrentIndex((this->currentIndex() + 1) % this->count());
    }
}

Unfortunately, however, the slot does seem to be getting activated.  I
suspect that the TextEdit widget is blocking the signal somehow.  Any help
is appreciated :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090125/9151b340/attachment.html 


More information about the Qt-interest-old mailing list