diff options
Diffstat (limited to 'src/widgets/doc')
6 files changed, 12 insertions, 298 deletions
diff --git a/src/widgets/doc/snippets/code/doc_src_styles.cpp b/src/widgets/doc/snippets/code/doc_src_styles.cpp index a70ed6b11d..3536be6e7b 100644 --- a/src/widgets/doc/snippets/code/doc_src_styles.cpp +++ b/src/widgets/doc/snippets/code/doc_src_styles.cpp @@ -81,11 +81,6 @@ state |= QStyle::State_MouseOver; if (widget->window()->isActiveWindow()) state |= QStyle::State_Active; -#if 0 // Used to be included in Qt4 for Q_WS_MAC - extern bool qt_mac_can_clickThrough(const QWidget *w); //qwidget_mac.cpp - if (!(state & QStyle::State_Active) && !qt_mac_can_clickThrough(widget)) - state &= ~QStyle::State_Enabled; -#endif #ifdef QT_KEYPAD_NAVIGATION if (widget->hasEditFocus()) state |= QStyle::State_HasEditFocus; diff --git a/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp b/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp index 39aca459db..7ccd827a04 100644 --- a/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp +++ b/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp @@ -155,3 +155,8 @@ auto fileOpenCompleted = [](const QString &fileName, const QByteArray &fileConte } QFileDialog::getOpenFileContent("Images (*.png *.xpm *.jpg)", fileContentReady); //! [15] + +//! [16] +QByteArray imageData; // obtained from e.g. QImage::save() +QFileDialog::saveFile("myimage.png", imageData); +//! [16] diff --git a/src/widgets/doc/snippets/macmainwindow.mm b/src/widgets/doc/snippets/macmainwindow.mm deleted file mode 100644 index c63796a3f2..0000000000 --- a/src/widgets/doc/snippets/macmainwindow.mm +++ /dev/null @@ -1,290 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "macmainwindow.h" -#import <AppKit/AppKit.h> -#include <QtGui> - - -#if 0 // Used to be included in Qt4 for Q_WS_MAC - -//![0] -SearchWidget::SearchWidget(QWidget *parent) - : QMacCocoaViewContainer(0, parent) -{ - // Many Cocoa objects create temporary autorelease objects, - // so create a pool to catch them. - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - - // Create the NSSearchField, set it on the QCocoaViewContainer. - NSSearchField *search = [[NSSearchField alloc] init]; - setCocoaView(search); - - // Use a Qt menu for the search field menu. - QMenu *qtMenu = createMenu(this); - NSMenu *nsMenu = qtMenu->macMenu(0); - [[search cell] setSearchMenuTemplate:nsMenu]; - - // Release our reference, since our super class takes ownership and we - // don't need it anymore. - [search release]; - - // Clean up our pool as we no longer need it. - [pool release]; -} -//![0] - -SearchWidget::~SearchWidget() -{ -} - -QSize SearchWidget::sizeHint() const -{ - return QSize(150, 40); -} - -QMenu *createMenu(QWidget *parent) -{ - QMenu *searchMenu = new QMenu(parent); - - QAction * indexAction = searchMenu->addAction("Index Search"); - indexAction->setCheckable(true); - indexAction->setChecked(true); - - QAction * fulltextAction = searchMenu->addAction("Full Text Search"); - fulltextAction->setCheckable(true); - - QActionGroup *searchActionGroup = new QActionGroup(parent); - searchActionGroup->addAction(indexAction); - searchActionGroup->addAction(fulltextAction); - searchActionGroup->setExclusive(true); - - return searchMenu; -} - -SearchWrapper::SearchWrapper(QWidget *parent) -:QWidget(parent) -{ - s = new SearchWidget(this); - s->move(2,2); - setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); -} - -QSize SearchWrapper::sizeHint() const -{ - return s->sizeHint() + QSize(6, 2); -} - -Spacer::Spacer(QWidget *parent) -:QWidget(parent) -{ - QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - setSizePolicy(sizePolicy); -} - -QSize Spacer::sizeHint() const -{ - return QSize(1, 1); -} - -MacSplitterHandle::MacSplitterHandle(Qt::Orientation orientation, QSplitter *parent) -: QSplitterHandle(orientation, parent) { } - -// Paint the horizontal handle as a gradient, paint -// the vertical handle as a line. -void MacSplitterHandle::paintEvent(QPaintEvent *) -{ - QPainter painter(this); - - QColor topColor(145, 145, 145); - QColor bottomColor(142, 142, 142); - QColor gradientStart(252, 252, 252); - QColor gradientStop(223, 223, 223); - - if (orientation() == Qt::Vertical) { - painter.setPen(topColor); - painter.drawLine(0, 0, width(), 0); - painter.setPen(bottomColor); - painter.drawLine(0, height() - 1, width(), height() - 1); - - QLinearGradient linearGrad(QPointF(0, 0), QPointF(0, height() -3)); - linearGrad.setColorAt(0, gradientStart); - linearGrad.setColorAt(1, gradientStop); - painter.fillRect(QRect(QPoint(0,1), size() - QSize(0, 2)), QBrush(linearGrad)); - } else { - painter.setPen(topColor); - painter.drawLine(0, 0, 0, height()); - } -} - -QSize MacSplitterHandle::sizeHint() const -{ - QSize parent = QSplitterHandle::sizeHint(); - if (orientation() == Qt::Vertical) { - return parent + QSize(0, 3); - } else { - return QSize(1, parent.height()); - } -} - -QSplitterHandle *MacSplitter::createHandle() -{ - return new MacSplitterHandle(orientation(), this); -} - -MacMainWindow::MacMainWindow() -{ - QSettings settings; - restoreGeometry(settings.value("Geometry").toByteArray()); - - setWindowTitle("Mac Main Window"); - - splitter = new MacSplitter(); - - // Set up the left-hand side blue side bar. - sidebar = new QTreeView(); - sidebar->setFrameStyle(QFrame::NoFrame); - sidebar->setAttribute(Qt::WA_MacShowFocusRect, false); - sidebar->setAutoFillBackground(true); - - // Set the palette. - QPalette palette = sidebar->palette(); - QColor macSidebarColor(231, 237, 246); - QColor macSidebarHighlightColor(168, 183, 205); - palette.setColor(QPalette::Base, macSidebarColor); - palette.setColor(QPalette::Highlight, macSidebarHighlightColor); - sidebar->setPalette(palette); - - sidebar->setModel(createItemModel()); - sidebar->header()->hide(); - sidebar->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - sidebar->setTextElideMode(Qt::ElideMiddle); - - splitter->addWidget(sidebar); - - horizontalSplitter = new MacSplitter(); - horizontalSplitter->setOrientation(Qt::Vertical); - splitter->addWidget(horizontalSplitter); - - splitter->setStretchFactor(0, 0); - splitter->setStretchFactor(1, 1); - - // Set up the top document list view. - documents = new QListView(); - documents->setFrameStyle(QFrame::NoFrame); - documents->setAttribute(Qt::WA_MacShowFocusRect, false); - documents->setModel(createDocumentModel()); - documents->setAlternatingRowColors(true); - documents->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - horizontalSplitter->addWidget(documents); - horizontalSplitter->setStretchFactor(0, 0); - - // Set up the text view. - textedit = new QTextEdit(); - textedit->setFrameStyle(QFrame::NoFrame); - textedit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - textedit->setText("<br><br><br><br><br><br><center><b>This demo shows how to create a \ - Qt main window application that has the same appearance as other \ - OS X applications such as Mail or iTunes. This includes \ - customizing the item views and QSplitter and wrapping native widgets \ - such as the search field.</b></center>"); - - horizontalSplitter->addWidget(textedit); - - setCentralWidget(splitter); - - toolBar = addToolBar(tr("Search")); - toolBar->addWidget(new Spacer()); - toolBar->addWidget(new SearchWrapper()); - - setUnifiedTitleAndToolBarOnMac(true); -} - -MacMainWindow::~MacMainWindow() -{ - QSettings settings; - settings.setValue("Geometry", saveGeometry()); -} - -QAbstractItemModel *MacMainWindow::createItemModel() -{ - QStandardItemModel *model = new QStandardItemModel(); - QStandardItem *parentItem = model->invisibleRootItem(); - - QStandardItem *documentationItem = new QStandardItem("Documentation"); - parentItem->appendRow(documentationItem); - - QStandardItem *assistantItem = new QStandardItem("Qt MainWindow Manual"); - documentationItem->appendRow(assistantItem); - - QStandardItem *designerItem = new QStandardItem("Qt Designer Manual"); - documentationItem->appendRow(designerItem); - - QStandardItem *qtItem = new QStandardItem("Qt Reference Documentation"); - qtItem->appendRow(new QStandardItem("Classes")); - qtItem->appendRow(new QStandardItem("Overviews")); - qtItem->appendRow(new QStandardItem("Tutorial & Examples")); - documentationItem->appendRow(qtItem); - - QStandardItem *bookmarksItem = new QStandardItem("Bookmarks"); - parentItem->appendRow(bookmarksItem); - bookmarksItem->appendRow(new QStandardItem("QWidget")); - bookmarksItem->appendRow(new QStandardItem("QObject")); - bookmarksItem->appendRow(new QStandardItem("QWizard")); - - return model; -} - -void MacMainWindow::resizeEvent(QResizeEvent *) -{ - if (toolBar) - toolBar->updateGeometry(); -} - -QAbstractItemModel *MacMainWindow::createDocumentModel() -{ - QStandardItemModel *model = new QStandardItemModel(); - QStandardItem *parentItem = model->invisibleRootItem(); - parentItem->appendRow(new QStandardItem("QWidget Class Reference")); - parentItem->appendRow(new QStandardItem("QObject Class Reference")); - parentItem->appendRow(new QStandardItem("QListView Class Reference")); - - return model; -} - -#endif diff --git a/src/widgets/doc/snippets/timeline/main.cpp b/src/widgets/doc/snippets/timeline/main.cpp index 74aa749254..4dfa2400d0 100644 --- a/src/widgets/doc/snippets/timeline/main.cpp +++ b/src/widgets/doc/snippets/timeline/main.cpp @@ -48,7 +48,7 @@ ** ****************************************************************************/ -#include <QtGui> +#include <QtWidgets> #include <math.h> int main(int argv, char *args[]) @@ -68,7 +68,7 @@ int main(int argv, char *args[]) for (int i = 0; i < 200; ++i) animation->setPosAt(i / 200.0, QPointF(i, i)); - QGraphicsScene *scene = new QGraphicsScene(); + QGraphicsScene *scene = new QGraphicsScene; scene->setSceneRect(0, 0, 250, 250); scene->addItem(ball); diff --git a/src/widgets/doc/src/model-view-programming.qdoc b/src/widgets/doc/src/model-view-programming.qdoc index 9335ff78c9..236582ef3f 100644 --- a/src/widgets/doc/src/model-view-programming.qdoc +++ b/src/widgets/doc/src/model-view-programming.qdoc @@ -1912,7 +1912,7 @@ \section3 Custom sorting models - QSortFilterProxyModel instances use Qt's built-in qStableSort() function to set up + QSortFilterProxyModel instances use std::stable_sort() function to set up mappings between items in the source model and those in the proxy model, allowing a sorted hierarchy of items to be exposed to views without modifying the structure of the source model. To provide custom sorting behavior, reimplement the diff --git a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc index 00323eace6..84233e4b62 100644 --- a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc +++ b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc @@ -549,6 +549,10 @@ If the property references an enum declared with Q_ENUMS, you should reference its constants by name, i.e., not their numeric value. + \note Use the qproperty syntax with care, as it modifies the + widget that is being painted. Also, the qproperty syntax is evaluated only + once, which is when the widget is polished by the style. This means that any + attempt to use them in pseudo-states such as QPushButton:hover, will not work. */ /*! |