📄 qmenubar.cpp
字号:
height = d->actionRect(d->actionList.first()).height(); height += spaceBelowMenuBar; } height += 2*fw; height += 2*vmargin; } int margin = 2*vmargin + 2*fw + spaceBelowMenuBar; if(d->leftWidget) height = qMax(d->leftWidget->sizeHint().height() + margin, height); if(d->rightWidget) height = qMax(d->rightWidget->sizeHint().height() + margin, height); if(as_gui_menubar) { QStyleOptionMenuItem opt; opt.init(this); opt.menuRect = rect(); opt.state = QStyle::State_None; opt.menuItemType = QStyleOptionMenuItem::Normal; opt.checkType = QStyleOptionMenuItem::NotCheckable; return style()->sizeFromContents(QStyle::CT_MenuBar, &opt, QSize(0, height), this).height(); //not pretty.. } return height;}/*! \internal*/void QMenuBarPrivate::_q_internalShortcutActivated(int id){ QAction *act = actionList.at(id); setCurrentAction(act, true, true);}void QMenuBarPrivate::_q_updateLayout(){ Q_Q(QMenuBar); itemsDirty = true; updateGeometries(); q->update();}/*! \internal This sets widget \a w to be shown directly on the left of the first or the right of the last menu item, depending on \a corner.*/void QMenuBar::setCornerWidget(QWidget *w, Qt::Corner corner){ Q_D(QMenuBar); switch (corner) { case Qt::TopLeftCorner: if (d->leftWidget) d->leftWidget->removeEventFilter(this); d->leftWidget = w; break; case Qt::TopRightCorner: if (d->rightWidget) d->rightWidget->removeEventFilter(this); d->rightWidget = w; break; default: qWarning("QMenuBar::setCornerWidget: Only TopLeftCorner and TopRightCorner are supported"); return; } if (w) { w->setParent(this); w->installEventFilter(this); } d->_q_updateLayout();}/*! \internal Returns the widget in the left of the first or the right of the last menu item, depending on \a corner.*/QWidget *QMenuBar::cornerWidget(Qt::Corner corner) const{ Q_D(const QMenuBar); QWidget *w = 0; switch(corner) { case Qt::TopLeftCorner: w = d->leftWidget; break; case Qt::TopRightCorner: w = d->rightWidget; break; default: qWarning("QMenuBar::cornerWidget: Only TopLeftCorner and TopRightCorner are supported"); break; } return w;}/*! \fn void QMenuBar::triggered(QAction *action) This signal is emitted when a menu action is selected; \a action is the action that caused the event to be sent. Normally, you connect each menu action to a single slot using QAction::triggered(), but sometimes you will want to connect several items to a single slot (most often if the user selects from an array). This signal is useful in such cases. \sa hovered(), QAction::triggered()*//*! \fn void QMenuBar::hovered(QAction *action) This signal is emitted when a menu action is highlighted; \a action is the action that caused the event to be sent. Often this is used to update status information. \sa triggered(), QAction::hovered()*/#ifdef QT3_SUPPORT/*! Use style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, this) instead.*/int QMenuBar::frameWidth() const{ return style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this);}int QMenuBar::insertAny(const QIcon *icon, const QString *text, const QObject *receiver, const char *member, const QKeySequence *shortcut, const QMenu *popup, int id, int index){ QAction *act = popup ? popup->menuAction() : new QAction(this); if(id != -1) static_cast<QMenuItem*>(act)->setId(id); if(icon) act->setIcon(*icon); if(text) act->setText(*text); if(shortcut) act->setShortcut(*shortcut); if(receiver && member) QObject::connect(act, SIGNAL(triggered()), receiver, member); if(index == -1 || index >= actions().count()) addAction(act); else insertAction(actions().value(index), act); return findIdForAction(act);}/*! Use insertAction() instead, using a separator action. For example, to add a separator after the previously added action use code like this: \code QAction *action = new QAction(this); action->setSeparator(true); menubar->addAction(action); \endcode*/int QMenuBar::insertSeparator(int index){ QAction *act = new QAction(this); act->setSeparator(true); if(index == -1 || index >= actions().count()) addAction(act); else insertAction(actions().value(index), act); return findIdForAction(act);}/*! Use QAction::setData() instead.*/bool QMenuBar::setItemParameter(int id, int param){ if(QAction *act = findActionForId(id)) { act->d_func()->param = param; return true; } return false;}/*! Use QAction::data() instead.*/int QMenuBar::itemParameter(int id) const{ if(QAction *act = findActionForId(id)) return act->d_func()->param; return id;}QAction *QMenuBar::findActionForId(int id) const{ QList<QAction *> list = actions(); for (int i = 0; i < list.size(); ++i) { QAction *act = list.at(i); if (findIdForAction(act) == id) return act; } return 0;}int QMenuBar::findIdForAction(QAction *act) const{ Q_ASSERT(act); return act->d_func()->id;}#endif/*! \enum QMenuBar::Separator \compat \value Never \value InWindowsStyle*//*! \fn uint QMenuBar::count() const Use actions().count() instead.*//*! \fn int QMenuBar::insertItem(const QString &text, const QObject *receiver, const char* member, const QKeySequence& shortcut, int id, int index) Use one of the insertAction() or addAction() overloads instead.*//*! \fn int QMenuBar::insertItem(const QIcon& icon, const QString &text, const QObject *receiver, const char* member, const QKeySequence& shortcut, int id, int index) Use one of the insertAction() or addAction() overloads instead.*//*! \fn int QMenuBar::insertItem(const QPixmap &pixmap, const QObject *receiver, const char* member, const QKeySequence& shortcut, int id, int index) Use one of the insertAction(), addAction(), insertMenu(), or addMenu() overloads instead.*//*! \fn int QMenuBar::insertItem(const QString &text, int id, int index) Use one of the insertAction() or addAction() overloads instead.*//*! \fn int QMenuBar::insertItem(const QIcon& icon, const QString &text, int id, int index) Use one of the insertAction(), addAction(), insertMenu(), or addMenu() overloads instead.*//*! \fn int QMenuBar::insertItem(const QString &text, QMenu *popup, int id, int index) Use one of the insertMenu(), or addMenu() overloads instead.*//*! \fn int QMenuBar::insertItem(const QIcon& icon, const QString &text, QMenu *popup, int id, int index) Use one of the insertMenu(), or addMenu() overloads instead.*//*! \fn int QMenuBar::insertItem(const QPixmap &pixmap, int id, int index) Use one of the insertAction(), addAction(), insertMenu(), or addMenu() overloads instead.*//*! \fn int QMenuBar::insertItem(const QPixmap &pixmap, QMenu *popup, int id, int index) Use one of the insertMenu(), or addMenu() overloads instead.*//*! \fn void QMenuBar::removeItem(int id) Use removeAction() instead.*//*! \fn void QMenuBar::removeItemAt(int index) Use removeAction() instead.*//*! \fn QKeySequence QMenuBar::accel(int id) const Use shortcut() on the relevant QAction instead.*//*! \fn void QMenuBar::setAccel(const QKeySequence& key, int id) Use setShortcut() on the relevant QAction instead.*//*! \fn QIcon QMenuBar::iconSet(int id) const Use icon() on the relevant QAction instead.*//*! \fn QString QMenuBar::text(int id) const Use text() on the relevant QAction instead.*//*! \fn QPixmap QMenuBar::pixmap(int id) const Use QPixmap(icon()) on the relevant QAction instead.*//*! \fn void QMenuBar::setWhatsThis(int id, const QString &w) Use setWhatsThis() on the relevant QAction instead.*//*! \fn QString QMenuBar::whatsThis(int id) const Use whatsThis() on the relevant QAction instead.*//*! \fn void QMenuBar::changeItem(int id, const QString &text) Use setText() on the relevant QAction instead.*//*! \fn void QMenuBar::changeItem(int id, const QPixmap &pixmap) Use setText() on the relevant QAction instead.*//*! \fn void QMenuBar::changeItem(int id, const QIcon &icon, const QString &text) Use setIcon() and setText() on the relevant QAction instead.*//*! \fn bool QMenuBar::isItemActive(int id) const Use activeAction() instead.*//*! \fn bool QMenuBar::isItemEnabled(int id) const Use isEnabled() on the relevant QAction instead.*//*! \fn void QMenuBar::setItemEnabled(int id, bool enable) Use setEnabled() on the relevant QAction instead.*//*! \fn bool QMenuBar::isItemChecked(int id) const Use isChecked() on the relevant QAction instead.*//*! \fn void QMenuBar::setItemChecked(int id, bool check) Use setChecked() on the relevant QAction instead.*//*! \fn bool QMenuBar::isItemVisible(int id) const Use isVisible() on the relevant QAction instead.*//*! \fn void QMenuBar::setItemVisible(int id, bool visible) Use setVisible() on the relevant QAction instead.*//*! \fn int QMenuBar::indexOf(int id) const Use actions().indexOf(action) on the relevant QAction instead.*//*! \fn int QMenuBar::idAt(int index) const Use actions instead.*//*! \fn void QMenuBar::activateItemAt(int index) Use activate() on the relevant QAction instead.*//*! \fn bool QMenuBar::connectItem(int id, const QObject *receiver, const char* member) Use connect() on the relevant QAction instead.*//*! \fn bool QMenuBar::disconnectItem(int id,const QObject *receiver, const char* member) Use disconnect() on the relevant QAction instead.*//*! \fn QMenuItem *QMenuBar::findItem(int id) const Use actions instead.*//*! \fn Separator QMenuBar::separator() const This function is provided only to make old code compile.*//*! \fn void QMenuBar::setSeparator(Separator sep) This function is provided only to make old code compile.*//*! \fn QRect QMenuBar::itemRect(int index) Use actionGeometry() on the relevant QAction instead.*//*! \fn int QMenuBar::itemAtPos(const QPoint &p) Use actionAt() instead.*//*! \fn void QMenuBar::activated(int itemId); Use triggered() instead.*//*! \fn void QMenuBar::highlighted(int itemId); Use hovered() instead.*/// for private slots#include <moc_qmenubar.cpp>#endif // QT_NO_MENUBAR
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -