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;
{
std::cout << "wanting to close" << std::endl;
closeTab(currentIndex());
}
}
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);
}
To copy to clipboard, switch view to plain text mode
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):
setMenuBar(m_menuBar);
// add the file menu
QAction * preferencesAction
= menuBar
()->addAction
(tr
("preferences"));
QMenu * preferencesMenu
= menuBar
()->addMenu
(tr
("preferences"));
m_menuBar = new QMenuBar(0);
setMenuBar(m_menuBar);
// add the file menu
QAction * preferencesAction = menuBar()->addAction(tr("preferences"));
QMenu * preferencesMenu = menuBar()->addMenu(tr("preferences"));
To copy to clipboard, switch view to plain text mode
neither option works... I do not get a "Preferences" menu option under the Application Menu. What am I doing wrong?
Bookmarks