PDA

View Full Version : QKeySequence not working in OSX 10.6? (Qt4.6.0beta1)



draculr
17th October 2009, 07:49
Hi, I have my own tabwidget subclassing from QTabWidget with the following bit of code:

void TabWidget::keyReleaseEvent(QKeyEvent* event)
{
std::cout << "key pressed" << std::endl;
if (event->matches(QKeySequence::Close))
{
std::cout << "wanting to close" << std::endl;
closeTab(currentIndex());
}
QTabWidget::keyReleaseEvent(event);
}

The problem is, on OSX 10.6 with Qt4.6.0beta1 i get "key pressed" but no match to any key sequence. It doesnt matter what the key sequence is, i dont get any thing else printed out.

Also, one other little question... I am trying to get "Preferences" in the application menu. The Qt documentation says "The merging functionality is based on string matching the title of a QMenu entry. These strings are translated (using QObject::tr()) in the "QMenuBar" context".

When I try to do that though it does not seem to work, eg (on my MainWindow class):


m_menuBar = new QMenuBar(0);
setMenuBar(m_menuBar);

// add the file menu
QAction * preferencesAction = menuBar()->addAction(tr("preferences"));
QMenu * preferencesMenu = menuBar()->addMenu(tr("preferences"));


neither option works... I do not get a "Preferences" menu option under the Application Menu. What am I doing wrong?