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

📄 qtoolbar.cpp

📁 qt-x11-opensource-src-4.1.4.tar.gz源码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    This signal is emitted when the toolbar becomes movable or fixed.    If the toolbar can be moved, \a movable is true; otherwise it is    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 window title is set to \a title. This title is used when the    toolbar is floating as an independent window. It is also 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) {        QMainWindowLayout *mainwin_layout = qobject_cast<QMainWindowLayout *>(mainwindow->layout());        mainwin_layout->removeToolBarInfo(this);        mainwin_layout->relayout();#ifdef Q_WS_MAC        if (mainwin_layout && mainwin_layout->tb_layout_info.isEmpty())            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->handle->setVisible(d->movable && (qobject_cast<QMainWindow *>(parentWidget()) != 0));    emit movableChanged(d->movable);}bool QToolBar::isMovable() const{ Q_D(const QToolBar); return d->movable; }/*!    \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); return d->allowedAreas; }/*! \property QToolBar::orientation    \brief orientation of the toolbar    The default is Qt::Horizontal.    The orientation is updated automatically when the toolbar is    managed by QMainWindow.*/void QToolBar::setOrientation(Qt::Orientation orientation){    Q_D(QToolBar);    if (orientation == d->orientation)        return;    d->orientation = orientation;    QBoxLayout *box = qobject_cast<QBoxLayout *>(layout());    Q_ASSERT_X(box != 0, "QToolBar::setOrientation", "internal error");    switch (d->orientation) {    case Qt::Vertical:	box->setDirection(QBoxLayout::TopToBottom);        box->setAlignment(Qt::AlignTop); 	setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));	break;    case Qt::Horizontal:	box->setDirection(QBoxLayout::LeftToRight);        box->setAlignment(Qt::AlignLeft); 	setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding));	break;    }    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 is Qt::AutomaticIconSize.*/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->widget() == this)                    sz = mw->iconSize();            } while (!sz.isValid() && item != 0);        }    }    if (!sz.isValid()) {        const int metric = style()->pixelMetric(QStyle::PM_ToolBarIconSize);        sz = QSize(metric, metric);    }    if (d->iconSize != sz) {        d->iconSize = sz;        setMinimumSize(0, 0);        emit iconSizeChanged(d->iconSize);    }    d->explicitIconSize = iconSize.isValid();}/*!    \property QToolBar::toolButtonStyle    \brief the style of toolbar buttons    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()), 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()), 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.    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){    QToolBarWidgetAction *action = new QToolBarWidgetAction(widget, this);    addAction(action);    return action;}/*!    Inserts the given \a widget in front of the toolbar item    associated with the \a before action.    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 addWidget()*/QAction *QToolBar::insertWidget(QAction *before, QWidget *widget){    QToolBarWidgetAction *action = new QToolBarWidgetAction(widget, this);    insertAction(before, action);    return action;}/*!    \internal

⌨️ 快捷键说明

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