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

📄 q3mainwindow.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    d->ttg = newToolTipGroup;    connect(toolTipGroup(), SIGNAL(showTip(QString)),            statusBar(), SLOT(showMessage(QString)));    connect(toolTipGroup(), SIGNAL(removeTip()),            statusBar(), SLOT(clearMessage()));}/*!    Returns this main window's tool tip group. If there isn't one,    toolTipGroup() creates an empty tool tip group.    \sa menuBar() statusBar()*/QToolTipGroup * Q3MainWindow::toolTipGroup() const{    Q_D(const Q3MainWindow);    if (d->ttg)        return d->ttg;    QToolTipGroup * t = new QToolTipGroup((Q3MainWindow*)this,                                           "automatic tool tip group");    ((Q3MainWindowPrivate*)d)->ttg = t;    return t;}#endif/*!    If \a enable is true then users can dock windows in the \a dock    area. If \a enable is false users cannot dock windows in the \a    dock dock area.    Users can dock (drag) dock windows into any enabled dock area.*/void Q3MainWindow::setDockEnabled(Qt::Dock dock, bool enable){    d_func()->docks.insert(dock, enable);}/*!    Returns true if the \a dock dock area is enabled, i.e. it can    accept user dragged dock windows; otherwise returns false.    \sa setDockEnabled()*/bool Q3MainWindow::isDockEnabled(Qt::Dock dock) const{    return d_func()->docks[dock];}/*!    \overload    Returns true if dock area \a area is enabled, i.e. it can accept    user dragged dock windows; otherwise returns false.    \sa setDockEnabled()*/bool Q3MainWindow::isDockEnabled(Q3DockArea *area) const{    Q_D(const Q3MainWindow);    if (area == d->leftDock)        return d->docks[Qt::DockLeft];    if (area == d->rightDock)        return d->docks[Qt::DockRight];    if (area == d->topDock)        return d->docks[Qt::DockTop];    if (area == d->bottomDock)        return d->docks[Qt::DockBottom];    return false;}/*!    \overload    If \a enable is true then users can dock the \a dw dock window in    the \a dock area. If \a enable is false users cannot dock the \a    dw dock window in the \a dock area.    In general users can dock (drag) dock windows into any enabled    dock area. Using this function particular dock areas can be    enabled (or disabled) as docking points for particular dock    windows.*/void Q3MainWindow::setDockEnabled(Q3DockWindow *dw, Qt::Dock dock, bool enable){    Q_D(Q3MainWindow);    if (d->dockWindows.contains(dw)) {        d->dockWindows.append(dw);        connect(dw, SIGNAL(placeChanged(Q3DockWindow::Place)),                 this, SLOT(slotPlaceChanged()));    }    QString s;    s.sprintf("%p_%d", (void*)dw, (int)dock);    if (enable)        d->disabledDocks.removeAll(s);    else if (!d->disabledDocks.contains(s))        d->disabledDocks << s;    switch (dock) {        case Qt::DockTop:            topDock()->setAcceptDockWindow(dw, enable);            break;        case Qt::DockLeft:            leftDock()->setAcceptDockWindow(dw, enable);            break;        case Qt::DockRight:            rightDock()->setAcceptDockWindow(dw, enable);            break;        case Qt::DockBottom:            bottomDock()->setAcceptDockWindow(dw, enable);            break;        default:            break;    }}/*!    \overload    Returns true if dock area \a area is enabled for the dock window    \a dw; otherwise returns false.    \sa setDockEnabled()*/bool Q3MainWindow::isDockEnabled(Q3DockWindow *dw, Q3DockArea *area) const{    Q_D(const Q3MainWindow);    if (!isDockEnabled(area))        return false;    Qt::Dock dock;    if (area == d->leftDock)        dock = Qt::DockLeft;    else if (area == d->rightDock)        dock = Qt::DockRight;    else if (area == d->topDock)        dock = Qt::DockTop;    else if (area == d->bottomDock)        dock = Qt::DockBottom;    else        return false;    return isDockEnabled(dw, dock);}/*!    \overload    Returns true if dock area \a dock is enabled for the dock window    \a tb; otherwise returns false.    \sa setDockEnabled()*/bool Q3MainWindow::isDockEnabled(Q3DockWindow *tb, Qt::Dock dock) const{    if (!isDockEnabled(dock))        return false;    QString s;    s.sprintf("%p_%d", (void*)tb, (int)dock);    return !d_func()->disabledDocks.contains(s);}/*!    Adds \a dockWindow to the \a edge dock area.    If \a newLine is false (the default) then the \a dockWindow is    added at the end of the \a edge. For vertical edges the end is at    the bottom, for horizontal edges (including \c Minimized) the end    is at the right. If \a newLine is true a new line of dock windows    is started with \a dockWindow as the first (left-most and    top-most) dock window.    If \a dockWindow is managed by another main window, it is first    removed from that window.*/void Q3MainWindow::addDockWindow(Q3DockWindow *dockWindow,                              Qt::Dock edge, bool newLine){    Q_D(Q3MainWindow);#ifdef Q_WS_MAC    extern WindowPtr qt_mac_window_for(const QWidget*); //qwidget_mac.cpp    if(isWindow() && edge == Qt::DockTop) {        d->createWinId();        ChangeWindowAttributes(qt_mac_window_for(this), kWindowToolbarButtonAttribute, 0);    }#endif    moveDockWindow(dockWindow, edge);    dockWindow->setNewLine(newLine);    if (!d->dockWindows.contains(dockWindow)) {        d->dockWindows.append(dockWindow);        connect(dockWindow, SIGNAL(placeChanged(Q3DockWindow::Place)),                 this, SLOT(slotPlaceChanged()));        dockWindow->installEventFilter(this);    }    dockWindow->setOpaqueMoving(d->opaque);}/*!    \overload    Adds \a dockWindow to the dock area with label \a label.    If \a newLine is false (the default) the \a dockWindow is added at    the end of the \a edge. For vertical edges the end is at the    bottom, for horizontal edges (including \c Minimized) the end is    at the right. If \a newLine is true a new line of dock windows is    started with \a dockWindow as the first (left-most and top-most)    dock window.    If \a dockWindow is managed by another main window, it is first    removed from that window.*/void Q3MainWindow::addDockWindow(Q3DockWindow * dockWindow, const QString &label,                              Qt::Dock edge, bool newLine){    addDockWindow(dockWindow, edge, newLine);#ifndef QT_NO_TOOLBAR    Q3ToolBar *tb = qobject_cast<Q3ToolBar*>(dockWindow);    if (tb)        tb->setLabel(label);#endif}/*!    Moves \a dockWindow to the end of the \a edge.    For vertical edges the end is at the bottom, for horizontal edges    (including \c Minimized) the end is at the right.    If \a dockWindow is managed by another main window, it is first    removed from that window.*/void Q3MainWindow::moveDockWindow(Q3DockWindow * dockWindow, Qt::Dock edge){    Q_D(Q3MainWindow);    Qt::Orientation oo = dockWindow->orientation();    switch (edge) {    case Qt::DockTop:        if (dockWindow->area() != d->topDock)            dockWindow->removeFromDock(false);        d->topDock->moveDockWindow(dockWindow);        emit dockWindowPositionChanged(dockWindow);        break;    case Qt::DockBottom:        if (dockWindow->area() != d->bottomDock)            dockWindow->removeFromDock(false);        d->bottomDock->moveDockWindow(dockWindow);        emit dockWindowPositionChanged(dockWindow);        break;    case Qt::DockRight:        if (dockWindow->area() != d->rightDock)            dockWindow->removeFromDock(false);        d->rightDock->moveDockWindow(dockWindow);        emit dockWindowPositionChanged(dockWindow);        break;    case Qt::DockLeft:        if (dockWindow->area() != d->leftDock)            dockWindow->removeFromDock(false);        d->leftDock->moveDockWindow(dockWindow);        emit dockWindowPositionChanged(dockWindow);        break;    case Qt::DockTornOff:        dockWindow->undock();        break;    case Qt::DockMinimized:        dockWindow->undock(d->hideDock);        break;    case Qt::DockUnmanaged:        break;    }    if (oo != dockWindow->orientation())        dockWindow->setOrientation(dockWindow->orientation());}/*!    \overload    Moves \a dockWindow to position \a index within the \a edge dock    area.    Any dock windows with positions \a index or higher have their    position number incremented and any of these on the same line are    moved right (down for vertical dock areas) to make room.    If \a nl is true, a new dock window line is created below the line    in which the moved dock window appears and the moved dock window,    with any others with higher positions on the same line, is moved    to this new line.    The \a extraOffset is the space to put between the left side of    the dock area (top side for vertical dock areas) and the dock    window. (This is mostly used for restoring dock windows to the    positions the user has dragged them to.)    If \a dockWindow is managed by another main window, it is first    removed from that window.*/void Q3MainWindow::moveDockWindow(Q3DockWindow * dockWindow, Qt::Dock edge, bool nl, int index, int extraOffset){    Q_D(Q3MainWindow);    Qt::Orientation oo = dockWindow->orientation();    dockWindow->setNewLine(nl);    dockWindow->setOffset(extraOffset);    switch (edge) {    case Qt::DockTop:        if (dockWindow->area() != d->topDock)            dockWindow->removeFromDock(false);        d->topDock->moveDockWindow(dockWindow, index);        break;    case Qt::DockBottom:        if (dockWindow->area() != d->bottomDock)            dockWindow->removeFromDock(false);        d->bottomDock->moveDockWindow(dockWindow, index);        break;    case Qt::DockRight:        if (dockWindow->area() != d->rightDock)            dockWindow->removeFromDock(false);        d->rightDock->moveDockWindow(dockWindow, index);        break;    case Qt::DockLeft:        if (dockWindow->area() != d->leftDock)            dockWindow->removeFromDock(false);        d->leftDock->moveDockWindow(dockWindow, index);        break;    case Qt::DockTornOff:        dockWindow->undock();        break;    case Qt::DockMinimized:        dockWindow->undock(d->hideDock);        break;    case Qt::DockUnmanaged:        break;    }    if (oo != dockWindow->orientation())        dockWindow->setOrientation(dockWindow->orientation());}/*!    Removes \a dockWindow from the main window's docking area,    provided \a dockWindow is non-null and managed by this main    window.*/void Q3MainWindow::removeDockWindow(Q3DockWindow * dockWindow){    Q_D(Q3MainWindow);#ifdef Q_WS_MAC    extern WindowPtr qt_mac_window_for(const QWidget*); //qwidget_mac.cpp    if(isWindow() && dockWindow->area() == topDock() && !dockWindows(Qt::DockTop).count())        ChangeWindowAttributes(qt_mac_window_for(this), 0, kWindowToolbarButtonAttribute);#endif    dockWindow->hide();    d->dockWindows.removeAll(dockWindow);    disconnect(dockWindow, SIGNAL(placeChanged(Q3DockWindow::Place)),                this, SLOT(slotPlaceChanged()));    dockWindow->removeEventFilter(this);}/*!    Sets up the geometry management of the window. It is called    automatically when needed, so you shouldn't need to call it.*/void Q3MainWindow::setUpLayout(){    Q_D(Q3MainWindow);#ifndef QT_NO_MENUBAR    if (!d->mb) {        // slightly evil hack here.  reconsider this        QObjectList l = queryList("QMenuBar", 0, false, false);        if (l.size())            d->mb = menuBar();    }#endif    if (!d->sb) {        // as above.        QObjectList l = queryList("QStatusBar", 0, false, false);        if (l.size())            d->sb = statusBar();    }    if (!d->tll) {        d->tll = new QBoxLayout(this, QBoxLayout::Down);        d->tll->setResizeMode(minimumSize().isNull() ? QLayout::Minimum : QLayout::FreeResize);    } else {        d->tll->setMenuBar(0);        QLayoutItem *item;        while ((item = d->tll->takeAt(0)))            delete item;    }#ifndef QT_NO_MENUBAR    if (d->mb && d->mb->isVisibleTo(this)) {        d->tll->setMenuBar(d->mb);        if (style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this))            d->tll->addSpacing(d->movable ? 1 : 2);    }#endif    d->tll->addWidget(d->hideDock);    if(d->topDock->parentWidget() == this)        d->tll->addWidget(d->topDock);    Q3MainWindowLayout *mwl = new Q3MainWindowLayout(this, d->tll);    d->tll->setStretchFactor(mwl, 1);    if(d->leftDock->parentWidget() == this)        mwl->setLeftDock(d->leftDock);    if (centralWidget())        mwl->setCentralWidget(centralWidget());    if(d->rightDock->parentWidget() == this)        mwl->setRightDock(d->rightDock);    d->mwl = mwl;    if(d->bottomDock->parentWidget() == this)        d->tll->addWidget(d->bottomDock);    if (d->sb && d->sb->parentWidget() == this) {

⌨️ 快捷键说明

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