⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qtoolbar.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    false.    \sa movable*//*!    \fn void QToolBar::orientationChanged(Qt::Orientation orientation)    This signal is emitted when the orientation of the toolbar changes.    The new orientation is specified by the \a orientation given.    \sa orientation*//*!    \fn void QToolBar::toolButtonStyleChanged(Qt::ToolButtonStyle toolButtonStyle)    This signal is emitted when the tool button style is changed. The    \a toolButtonStyle parameter holds the toolbar's new tool button    style.    \sa toolButtonStyle QMainWindow::toolButtonStyle*//*!    Constructs a QToolBar with the given \a parent.*/QToolBar::QToolBar(QWidget *parent)    : QWidget(*new QToolBarPrivate, parent, 0){    Q_D(QToolBar);    d->init();}/*!    Constructs a QToolBar with the given \a parent.    The given window \a title identifies the toolbar and is shown in    the context menu provided by QMainWindow.    \sa setWindowTitle()*/QToolBar::QToolBar(const QString &title, QWidget *parent)    : QWidget(*new QToolBarPrivate, parent, 0){    Q_D(QToolBar);    d->init();    setWindowTitle(title);}#ifdef QT3_SUPPORT/*! \obsolete    Constructs a QToolBar with the given \a parent and \a name.*/QToolBar::QToolBar(QWidget *parent, const char *name)    : QWidget(*new QToolBarPrivate, parent, 0){    Q_D(QToolBar);    d->init();    setObjectName(QString::fromAscii(name));}#endif/*!    Destroys the toolbar.*/QToolBar::~QToolBar(){    // Remove the toolbar button if there is nothing left.    QMainWindow *mainwindow = qobject_cast<QMainWindow *>(parentWidget());    if (mainwindow) {#ifdef Q_WS_MAC        QMainWindowLayout *mainwin_layout = qobject_cast<QMainWindowLayout *>(mainwindow->layout());        if (mainwin_layout && mainwin_layout->layoutState.toolBarAreaLayout.isEmpty()                && mainwindow->testAttribute(Qt::WA_WState_Created))            ChangeWindowAttributes(qt_mac_window_for(mainwindow), kWindowNoAttributes,                                   kWindowToolbarButtonAttribute);#endif    }}/*! \property QToolBar::movable    \brief whether the user can move the toolbar within the toolbar area,    or between toolbar areas    By default, this property is true.    This property only makes sense if the toolbar is in a    QMainWindow.    \sa allowedAreas*/void QToolBar::setMovable(bool movable){    Q_D(QToolBar);    if (!movable == !d->movable)        return;    d->movable = movable;    d->layout->invalidate();    emit movableChanged(d->movable);}bool QToolBar::isMovable() const{    Q_D(const QToolBar);    return d->movable;}/*!    \property QToolBar::floatable    \brief whether the toolbar can be dragged and dropped as an independent window.    The default is true.*/bool QToolBar::isFloatable() const{    Q_D(const QToolBar);    return d->floatable;}void QToolBar::setFloatable(bool floatable){    Q_D(QToolBar);    d->floatable = floatable;}/*!    \property QToolBar::floating    \brief whether the toolbar is an independent window.    \sa QWidget::isWindow()*/bool QToolBar::isFloating() const{    return isWindow();}/*!    \property QToolBar::allowedAreas    \brief areas where the toolbar may be placed    The default is Qt::AllToolBarAreas.    This property only makes sense if the toolbar is in a    QMainWindow.    \sa movable*/void QToolBar::setAllowedAreas(Qt::ToolBarAreas areas){    Q_D(QToolBar);    areas &= Qt::ToolBarArea_Mask;    if (areas == d->allowedAreas)        return;    d->allowedAreas = areas;    emit allowedAreasChanged(d->allowedAreas);}Qt::ToolBarAreas QToolBar::allowedAreas() const{    Q_D(const QToolBar);#ifdef Q_WS_MAC    if (QMainWindow *window = qobject_cast<QMainWindow *>(parentWidget())) {        if (window->unifiedTitleAndToolBarOnMac()) // Don't allow drags to the top (for now).            return (d->allowedAreas & ~Qt::TopToolBarArea);    }#endif    return d->allowedAreas;}/*! \property QToolBar::orientation    \brief orientation of the toolbar    The default is Qt::Horizontal.    This function should not be used when the toolbar is managed    by QMainWindow. You can use QMainWindow::addToolBar() or    QMainWindow::insertToolBar() if you wish to move a toolbar (that    is already added to a main window) to another Qt::ToolBarArea.*/void QToolBar::setOrientation(Qt::Orientation orientation){    Q_D(QToolBar);    if (orientation == d->orientation)        return;    d->orientation = orientation;    if (orientation == Qt::Vertical) 	setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred));    else 	setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));    d->layout->invalidate();    d->layout->activate();    emit orientationChanged(d->orientation);}Qt::Orientation QToolBar::orientation() const{ Q_D(const QToolBar); return d->orientation; }/*!    \property QToolBar::iconSize    \brief size of icons in the toolbar.    The default size is determined by the application's style and is    derived from the QStyle::PM_ToolBarIconSize pixel metric. It is    the maximum size an icon can have. Icons of smaller size will not    be scaled up.*/QSize QToolBar::iconSize() const{ Q_D(const QToolBar); return d->iconSize; }void QToolBar::setIconSize(const QSize &iconSize){    Q_D(QToolBar);    QSize sz = iconSize;    if (!sz.isValid()) {        QMainWindow *mw = qobject_cast<QMainWindow *>(parentWidget());        if (mw && mw->layout()) {            QLayout *layout = mw->layout();            int i = 0;            QLayoutItem *item = 0;            do {                item = layout->itemAt(i++);                if (item && (item->widget() == this))                    sz = mw->iconSize();            } while (!sz.isValid() && item != 0);        }    }    if (!sz.isValid()) {        const int metric = style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, this);        sz = QSize(metric, metric);    }    if (d->iconSize != sz) {        d->iconSize = sz;        setMinimumSize(0, 0);        emit iconSizeChanged(d->iconSize);    }    d->explicitIconSize = iconSize.isValid();    d->layout->invalidate();}/*!    \property QToolBar::toolButtonStyle    \brief the style of toolbar buttons    This property defines the style of all tool buttons that are added    as \l{QAction}s. Note that if you add a QToolButton with the    addWidget() method, it will not get this button style.    The default is Qt::ToolButtonIconOnly.*/Qt::ToolButtonStyle QToolBar::toolButtonStyle() const{ Q_D(const QToolBar); return d->toolButtonStyle; }void QToolBar::setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle){    Q_D(QToolBar);    d->explicitToolButtonStyle = true;    if (d->toolButtonStyle == toolButtonStyle)        return;    d->toolButtonStyle = toolButtonStyle;    setMinimumSize(0, 0);    emit toolButtonStyleChanged(d->toolButtonStyle);}/*!    Removes all actions from the toolbar.    \sa removeAction()*/void QToolBar::clear(){    QList<QAction *> actions = this->actions();    for(int i = 0; i < actions.size(); i++)        removeAction(actions.at(i));}/*!    \overload    Creates a new action with the given \a text. This action is added to    the end of the toolbar.*/QAction *QToolBar::addAction(const QString &text){    QAction *action = new QAction(text, this);    addAction(action);    return action;}/*!    \overload    Creates a new action with the given \a icon and \a text. This    action is added to the end of the toolbar.*/QAction *QToolBar::addAction(const QIcon &icon, const QString &text){    QAction *action = new QAction(icon, text, this);    addAction(action);    return action;}/*!    \overload    Creates a new action with the given \a text. This action is added to    the end of the toolbar. The action's \link QAction::triggered()    triggered()\endlink signal is connected to \a member in \a    receiver.*/QAction *QToolBar::addAction(const QString &text,                             const QObject *receiver, const char* member){    QAction *action = new QAction(text, this);    QObject::connect(action, SIGNAL(triggered(bool)), receiver, member);    addAction(action);    return action;}/*!    \overload    Creates a new action with the icon \a icon and text \a text. This    action is added to the end of the toolbar. The action's \link    QAction::triggered() triggered()\endlink signal is connected to \a    member in \a receiver.*/QAction *QToolBar::addAction(const QIcon &icon, const QString &text,                             const QObject *receiver, const char* member){    QAction *action = new QAction(icon, text, this);    QObject::connect(action, SIGNAL(triggered(bool)), receiver, member);    addAction(action);    return action;}/*!     Adds a separator to the end of the toolbar.     \sa insertSeparator()*/QAction *QToolBar::addSeparator(){    QAction *action = new QAction(this);    action->setSeparator(true);    addAction(action);    return action;}/*!    Inserts a separator into the toolbar in front of the toolbar    item associated with the \a before action.    \sa addSeparator()*/QAction *QToolBar::insertSeparator(QAction *before){    QAction *action = new QAction(this);    action->setSeparator(true);    insertAction(before, action);    return action;}/*!    Adds the given \a widget to the toolbar as the toolbar's last    item.    If you add a QToolButton with this method, the tools bar's    Qt::ToolButtonStyle will not be respected.    Note: You should use QAction::setVisible() to change the    visibility of the widget. Using QWidget::setVisible(),    QWidget::show() and QWidget::hide() does not work.    \sa insertWidget()*/QAction *QToolBar::addWidget(QWidget *widget){    QWidgetAction *action = new QWidgetAction(this);    action->setDefaultWidget(widget);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -