diff options
author | Liang Qi <liang.qi@qt.io> | 2018-06-07 19:10:53 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2018-06-07 19:10:53 +0200 |
commit | 096e37910d93f9c52976600e985c615ea36fe291 (patch) | |
tree | 713d020f4a04f03d8ca6e111055e7eebe85953a8 /examples | |
parent | 88eda007a3b5046999dd0b287634765efcd8934d (diff) | |
parent | a14a943f9ac3d1e85514d7fb6688c84e624ac850 (diff) |
Merge remote-tracking branch 'origin/5.11' into dev
Conflicts:
.qmake.conf
src/corelib/kernel/qeventdispatcher_cf.mm
src/gui/kernel/qguiapplication_p.h
src/gui/kernel/qwindowsysteminterface.cpp
src/gui/kernel/qwindowsysteminterface.h
src/plugins/platforms/cocoa/qcocoawindow.mm
src/plugins/platforms/cocoa/qnswindowdelegate.mm
src/plugins/platforms/ios/qioseventdispatcher.mm
src/plugins/platforms/windows/qwindowsdrag.h
src/plugins/platforms/windows/qwindowsinternalmimedata.h
src/plugins/platforms/windows/qwindowsmime.cpp
src/plugins/platforms/winrt/qwinrtscreen.cpp
Change-Id: Ic817f265c2386e83839d2bb9ef7419cb29705246
Diffstat (limited to 'examples')
24 files changed, 425 insertions, 237 deletions
diff --git a/examples/network/torrent/mainwindow.cpp b/examples/network/torrent/mainwindow.cpp index f80c2c6975..660472c05c 100644 --- a/examples/network/torrent/mainwindow.cpp +++ b/examples/network/torrent/mainwindow.cpp @@ -62,7 +62,7 @@ class TorrentView : public QTreeWidget public: TorrentView(QWidget *parent = 0); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) signals: void fileDropped(const QString &fileName); @@ -702,12 +702,12 @@ void MainWindow::closeEvent(QCloseEvent *) TorrentView::TorrentView(QWidget *parent) : QTreeWidget(parent) { -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) setAcceptDrops(true); #endif } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) void TorrentView::dragMoveEvent(QDragMoveEvent *event) { // Accept file actions with a '.torrent' extension. diff --git a/examples/sql/books/bookdelegate.cpp b/examples/sql/books/bookdelegate.cpp index 6a42fd2db7..4115f80cf3 100644 --- a/examples/sql/books/bookdelegate.cpp +++ b/examples/sql/books/bookdelegate.cpp @@ -62,15 +62,21 @@ void BookDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, { if (index.column() != 5) { QStyleOptionViewItem opt = option; - opt.rect.adjust(0, 0, -1, -1); // since we draw the grid ourselves + // Since we draw the grid ourselves: + opt.rect.adjust(0, 0, -1, -1); QSqlRelationalDelegate::paint(painter, opt, index); } else { const QAbstractItemModel *model = index.model(); QPalette::ColorGroup cg = (option.state & QStyle::State_Enabled) ? - (option.state & QStyle::State_Active) ? QPalette::Normal : QPalette::Inactive : QPalette::Disabled; + (option.state & QStyle::State_Active) ? + QPalette::Normal : + QPalette::Inactive : + QPalette::Disabled; if (option.state & QStyle::State_Selected) - painter->fillRect(option.rect, option.palette.color(cg, QPalette::Highlight)); + painter->fillRect( + option.rect, + option.palette.color(cg, QPalette::Highlight)); int rating = model->data(index, Qt::DisplayRole).toInt(); int width = star.width(); @@ -81,7 +87,8 @@ void BookDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, painter->drawPixmap(x, y, star); x += width; } - drawFocus(painter, option, option.rect.adjusted(0, 0, -1, -1)); // since we draw the grid ourselves + // Since we draw the grid ourselves: + drawFocus(painter, option, option.rect.adjusted(0, 0, -1, -1)); } QPen pen = painter->pen(); @@ -96,8 +103,8 @@ QSize BookDelegate::sizeHint(const QStyleOptionViewItem &option, { if (index.column() == 5) return QSize(5 * star.width(), star.height()) + QSize(1, 1); - - return QSqlRelationalDelegate::sizeHint(option, index) + QSize(1, 1); // since we draw the grid ourselves + // Since we draw the grid ourselves: + return QSqlRelationalDelegate::sizeHint(option, index) + QSize(1, 1); } bool BookDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, @@ -112,19 +119,21 @@ bool BookDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, int stars = qBound(0, int(0.7 + qreal(mouseEvent->pos().x() - option.rect.x()) / star.width()), 5); model->setData(index, QVariant(stars)); - return false; //so that the selection can change + // So that the selection can change: + return false; } return true; } -QWidget *BookDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, +QWidget *BookDelegate::createEditor(QWidget *parent, + const QStyleOptionViewItem &option, const QModelIndex &index) const { if (index.column() != 4) return QSqlRelationalDelegate::createEditor(parent, option, index); - // for editing the year, return a spinbox with a range from -1000 to 2100. + // For editing the year, return a spinbox with a range from -1000 to 2100. QSpinBox *sb = new QSpinBox(parent); sb->setFrame(false); sb->setMaximum(2100); @@ -132,4 +141,3 @@ QWidget *BookDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem return sb; } - diff --git a/examples/sql/books/bookdelegate.h b/examples/sql/books/bookdelegate.h index d07f2b9534..f1b4326992 100644 --- a/examples/sql/books/bookdelegate.h +++ b/examples/sql/books/bookdelegate.h @@ -66,14 +66,15 @@ public: void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; - QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; + QSize sizeHint(const QStyleOptionViewItem &option, + const QModelIndex &index) const override; bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override; QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, - const QModelIndex &index) const override; + const QModelIndex &index) const override; private: QPixmap star; diff --git a/examples/sql/books/bookwindow.cpp b/examples/sql/books/bookwindow.cpp index 1428bc04b5..d85b438956 100644 --- a/examples/sql/books/bookwindow.cpp +++ b/examples/sql/books/bookwindow.cpp @@ -59,53 +59,61 @@ BookWindow::BookWindow() ui.setupUi(this); if (!QSqlDatabase::drivers().contains("QSQLITE")) - QMessageBox::critical(this, "Unable to load database", "This demo needs the SQLITE driver"); + QMessageBox::critical( + this, + "Unable to load database", + "This demo needs the SQLITE driver" + ); - // initialize the database + // Initialize the database: QSqlError err = initDb(); if (err.type() != QSqlError::NoError) { showError(err); return; } - // Create the data model + // Create the data model: model = new QSqlRelationalTableModel(ui.bookTable); model->setEditStrategy(QSqlTableModel::OnManualSubmit); model->setTable("books"); - // Remember the indexes of the columns + // Remember the indexes of the columns: authorIdx = model->fieldIndex("author"); genreIdx = model->fieldIndex("genre"); - // Set the relations to the other database tables + // Set the relations to the other database tables: model->setRelation(authorIdx, QSqlRelation("authors", "id", "name")); model->setRelation(genreIdx, QSqlRelation("genres", "id", "name")); - // Set the localized header captions + // Set the localized header captions: model->setHeaderData(authorIdx, Qt::Horizontal, tr("Author Name")); model->setHeaderData(genreIdx, Qt::Horizontal, tr("Genre")); - model->setHeaderData(model->fieldIndex("title"), Qt::Horizontal, tr("Title")); + model->setHeaderData(model->fieldIndex("title"), + Qt::Horizontal, tr("Title")); model->setHeaderData(model->fieldIndex("year"), Qt::Horizontal, tr("Year")); - model->setHeaderData(model->fieldIndex("rating"), Qt::Horizontal, tr("Rating")); + model->setHeaderData(model->fieldIndex("rating"), + Qt::Horizontal, tr("Rating")); - // Populate the model + // Populate the model: if (!model->select()) { showError(model->lastError()); return; } - // Set the model and hide the ID column + // Set the model and hide the ID column: ui.bookTable->setModel(model); ui.bookTable->setItemDelegate(new BookDelegate(ui.bookTable)); ui.bookTable->setColumnHidden(model->fieldIndex("id"), true); ui.bookTable->setSelectionMode(QAbstractItemView::SingleSelection); - // Initialize the Author combo box + // Initialize the Author combo box: ui.authorEdit->setModel(model->relationModel(authorIdx)); - ui.authorEdit->setModelColumn(model->relationModel(authorIdx)->fieldIndex("name")); + ui.authorEdit->setModelColumn( + model->relationModel(authorIdx)->fieldIndex("name")); ui.genreEdit->setModel(model->relationModel(genreIdx)); - ui.genreEdit->setModelColumn(model->relationModel(genreIdx)->fieldIndex("name")); + ui.genreEdit->setModelColumn( + model->relationModel(genreIdx)->fieldIndex("name")); QDataWidgetMapper *mapper = new QDataWidgetMapper(this); mapper->setModel(model); @@ -116,8 +124,11 @@ BookWindow::BookWindow() mapper->addMapping(ui.genreEdit, genreIdx); mapper->addMapping(ui.ratingEdit, model->fieldIndex("rating")); - connect(ui.bookTable->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), - mapper, SLOT(setCurrentModelIndex(QModelIndex))); + connect(ui.bookTable->selectionModel(), + &QItemSelectionModel::currentRowChanged, + mapper, + &QDataWidgetMapper::setCurrentModelIndex + ); ui.bookTable->setCurrentIndex(model->index(0, 0)); } @@ -127,4 +138,3 @@ void BookWindow::showError(const QSqlError &err) QMessageBox::critical(this, "Unable to initialize Database", "Error initializing database: " + err.text()); } - diff --git a/examples/sql/books/bookwindow.ui b/examples/sql/books/bookwindow.ui index 659d324564..c81a86cb2c 100644 --- a/examples/sql/books/bookwindow.ui +++ b/examples/sql/books/bookwindow.ui @@ -1,10 +1,8 @@ -<ui version="4.0" > - <author></author> - <comment></comment> - <exportmacro></exportmacro> +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> <class>BookWindow</class> - <widget class="QMainWindow" name="BookWindow" > - <property name="geometry" > + <widget class="QMainWindow" name="BookWindow"> + <property name="geometry"> <rect> <x>0</x> <y>0</y> @@ -12,117 +10,135 @@ <height>420</height> </rect> </property> - <property name="windowTitle" > + <property name="windowTitle"> <string>Books</string> </property> - <widget class="QWidget" name="centralWidget" > - <layout class="QVBoxLayout" > - <property name="margin" > + <widget class="QWidget" name="centralWidget"> + <layout class="QVBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="leftMargin"> <number>9</number> </property> - <property name="spacing" > - <number>6</number> + <property name="topMargin"> + <number>9</number> + </property> + <property name="rightMargin"> + <number>9</number> + </property> + <property name="bottomMargin"> + <number>9</number> </property> <item> - <widget class="QGroupBox" name="groupBox" > - <property name="title" > + <widget class="QGroupBox" name="groupBox"> + <property name="title"> <string>Books</string> </property> - <layout class="QVBoxLayout" > - <property name="margin" > + <layout class="QVBoxLayout"> + <property name="spacing"> + <number>6</number> + </property> + <property name="leftMargin"> <number>9</number> </property> - <property name="spacing" > - <number>6</number> + <property name="topMargin"> + <number>9</number> + </property> + <property name="rightMargin"> + <number>9</number> + </property> + <property name="bottomMargin"> + <number>9</number> </property> <item> - <widget class="QTableView" name="bookTable" > - <property name="selectionBehavior" > + <widget class="QTableView" name="bookTable"> + <property name="selectionBehavior"> <enum>QAbstractItemView::SelectRows</enum> </property> </widget> </item> <item> - <widget class="QGroupBox" name="groupBox_2" > - <property name="title" > + <widget class="QGroupBox" name="groupBox_2"> + <property name="title"> <string>Details</string> </property> - <layout class="QFormLayout" > - <item row="0" column="0" > - <widget class="QLabel" name="label_5" > - <property name="text" > - <string><b>Title:</b></string> + <layout class="QFormLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label_5"> + <property name="text"> + <string><b>Title:</b></string> </property> </widget> </item> - <item row="0" column="1" > - <widget class="QLineEdit" name="titleEdit" > - <property name="enabled" > + <item row="0" column="1"> + <widget class="QLineEdit" name="titleEdit"> + <property name="enabled"> <bool>true</bool> </property> </widget> </item> - <item row="1" column="0" > - <widget class="QLabel" name="label_2_2_2_2" > - <property name="text" > - <string><b>Author: </b></string> + <item row="1" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string><b>Author: </b></string> </property> </widget> - </item> - <item row="1" column="1" > - <widget class="QComboBox" name="authorEdit" > - <property name="enabled" > + </item> + <item row="1" column="1"> + <widget class="QComboBox" name="authorEdit"> + <property name="enabled"> <bool>true</bool> </property> </widget> - </item> - <item row="2" column="0" > - <widget class="QLabel" name="label_3" > - <property name="text" > - <string><b>Genre:</b></string> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string><b>Genre:</b></string> </property> </widget> </item> - <item row="2" column="1" > - <widget class="QComboBox" name="genreEdit" > - <property name="enabled" > + <item row="2" column="1"> + <widget class="QComboBox" name="genreEdit"> + <property name="enabled"> <bool>true</bool> </property> </widget> </item> - <item row="3" column="0" > - <widget class="QLabel" name="label_4" > - <property name="text" > - <string><b>Year:</b></string> + <item row="3" column="0"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string><b>Year:</b></string> </property> </widget> - </item> - <item row="3" column="1" > - <widget class="QSpinBox" name="yearEdit" > - <property name="enabled" > + </item> + <item row="3" column="1"> + <widget class="QSpinBox" name="yearEdit"> + <property name="enabled"> <bool>true</bool> </property> - <property name="prefix" > + <property name="prefix"> <string/> </property> - <property name="maximum" > - <number>2100</number> - </property> - <property name="minimum" > + <property name="minimum"> <number>-1000</number> </property> + <property name="maximum"> + <number>2100</number> + </property> </widget> </item> - <item row="4" column="0" > - <widget class="QLabel" name="label" > - <property name="text" > - <string><b>Rating:</b></string> + <item row="4" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string><b>Rating:</b></string> </property> </widget> </item> - <item row="4" column="1" > - <widget class="QSpinBox" name="ratingEdit" > - <property name="maximum" > + <item row="4" column="1"> + <widget class="QSpinBox" name="ratingEdit"> + <property name="maximum"> <number>5</number> </property> </widget> @@ -136,7 +152,6 @@ </layout> </widget> </widget> - <pixmapfunction></pixmapfunction> <tabstops> <tabstop>bookTable</tabstop> <tabstop>titleEdit</tabstop> diff --git a/examples/widgets/graphicsview/graphicsview.pro b/examples/widgets/graphicsview/graphicsview.pro index 5a054fe6b2..b9bef70a0e 100644 --- a/examples/widgets/graphicsview/graphicsview.pro +++ b/examples/widgets/graphicsview/graphicsview.pro @@ -13,7 +13,7 @@ SUBDIRS = \ simpleanchorlayout \ weatheranchorlayout -contains(DEFINES, QT_NO_CURSOR)|contains(DEFINES, QT_NO_DRAGANDDROP): SUBDIRS -= dragdroprobot +contains(DEFINES, QT_NO_CURSOR)|!qtConfig(draganddrop): SUBDIRS -= dragdroprobot qtHaveModule(opengl):!qtConfig(opengles.):!qtConfig(dynamicgl) { SUBDIRS += boxes diff --git a/examples/widgets/itemviews/itemviews.pro b/examples/widgets/itemviews/itemviews.pro index 75307bd74e..b4a002c156 100644 --- a/examples/widgets/itemviews/itemviews.pro +++ b/examples/widgets/itemviews/itemviews.pro @@ -20,5 +20,5 @@ SUBDIRS = addressbook \ spreadsheet \ stardelegate \ storageview -contains(DEFINES, QT_NO_DRAGANDDROP): SUBDIRS -= puzzle +!qtConfig(draganddrop): SUBDIRS -= puzzle !qtHaveModule(xml): SUBDIRS -= simpledommodel diff --git a/examples/widgets/tools/plugandpaint/app/main.cpp b/examples/widgets/tools/plugandpaint/app/main.cpp index f157957da5..f50fd86b97 100644 --- a/examples/widgets/tools/plugandpaint/app/main.cpp +++ b/examples/widgets/tools/plugandpaint/app/main.cpp @@ -50,8 +50,9 @@ //! [0] #include "mainwindow.h" -#include <QtPlugin> + #include <QApplication> +#include <QtPlugin> Q_IMPORT_PLUGIN(BasicToolsPlugin) diff --git a/examples/widgets/tools/plugandpaint/app/mainwindow.cpp b/examples/widgets/tools/plugandpaint/app/mainwindow.cpp index 12c65e9364..ebe1150eea 100644 --- a/examples/widgets/tools/plugandpaint/app/mainwindow.cpp +++ b/examples/widgets/tools/plugandpaint/app/mainwindow.cpp @@ -54,19 +54,18 @@ #include "paintarea.h" #include "plugindialog.h" -#include <QPluginLoader> -#include <QTimer> - -#include <QScrollArea> -#include <QMessageBox> -#include <QActionGroup> #include <QAction> -#include <QMenu> -#include <QMenuBar> -#include <QFileDialog> +#include <QActionGroup> +#include <QApplication> #include <QColorDialog> +#include <QFileDialog> #include <QInputDialog> -#include <QApplication> +#include <QMenu> +#include <QMenuBar> +#include <QMessageBox> +#include <QPluginLoader> +#include <QScrollArea> +#include <QTimer> MainWindow::MainWindow() : paintArea(new PaintArea), @@ -85,7 +84,7 @@ MainWindow::MainWindow() : if (!brushActionGroup->actions().isEmpty()) brushActionGroup->actions().first()->trigger(); - QTimer::singleShot(500, this, SLOT(aboutPlugins())); + QTimer::singleShot(500, this, &MainWindow::aboutPlugins); } void MainWindow::open() @@ -109,11 +108,10 @@ bool MainWindow::saveAs() const QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), initialPath); - if (fileName.isEmpty()) { + if (fileName.isEmpty()) return false; - } else { - return paintArea->saveImage(fileName, "png"); - } + + return paintArea->saveImage(fileName, "png"); } void MainWindow::brushColor() @@ -137,8 +135,8 @@ void MainWindow::brushWidth() //! [0] void MainWindow::changeBrush() { - QAction *action = qobject_cast<QAction *>(sender()); - BrushInterface *iBrush = qobject_cast<BrushInterface *>(action->parent()); + auto action = qobject_cast<QAction *>(sender()); + auto iBrush = qobject_cast<BrushInterface *>(action->parent()); const QString brush = action->text(); paintArea->setBrush(iBrush, brush); @@ -148,8 +146,8 @@ void MainWindow::changeBrush() //! [1] void MainWindow::insertShape() { - QAction *action = qobject_cast<QAction *>(sender()); - ShapeInterface *iShape = qobject_cast<ShapeInterface *>(action->parent()); + auto action = qobject_cast<QAction *>(sender()); + auto iShape = qobject_cast<ShapeInterface *>(action->parent()); const QPainterPath path = iShape->generateShape(action->text(), this); if (!path.isEmpty()) @@ -160,9 +158,8 @@ void MainWindow::insertShape() //! [2] void MainWindow::applyFilter() { - QAction *action = qobject_cast<QAction *>(sender()); - FilterInterface *iFilter = - qobject_cast<FilterInterface *>(action->parent()); + auto action = qobject_cast<QAction *>(sender()); + auto iFilter = qobject_cast<FilterInterface *>(action->parent()); const QImage image = iFilter->filterImage(action->text(), paintArea->image(), this); @@ -189,32 +186,32 @@ void MainWindow::createActions() { openAct = new QAction(tr("&Open..."), this); openAct->setShortcuts(QKeySequence::Open); - connect(openAct, SIGNAL(triggered()), this, SLOT(open())); + connect(openAct, &QAction::triggered, this, &MainWindow::open); saveAsAct = new QAction(tr("&Save As..."), this); saveAsAct->setShortcuts(QKeySequence::SaveAs); - connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs())); + connect(saveAsAct, &QAction::triggered, this, &MainWindow::saveAs); exitAct = new QAction(tr("E&xit"), this); exitAct->setShortcuts(QKeySequence::Quit); - connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); + connect(exitAct, &QAction::triggered, this, &MainWindow::close); brushColorAct = new QAction(tr("&Brush Color..."), this); - connect(brushColorAct, SIGNAL(triggered()), this, SLOT(brushColor())); + connect(brushColorAct, &QAction::triggered, this, &MainWindow::brushColor); brushWidthAct = new QAction(tr("&Brush Width..."), this); - connect(brushWidthAct, SIGNAL(triggered()), this, SLOT(brushWidth())); + connect(brushWidthAct, &QAction::triggered, this, &MainWindow::brushWidth); brushActionGroup = new QActionGroup(this); aboutAct = new QAction(tr("&About"), this); - connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); + connect(aboutAct, &QAction::triggered, this, &MainWindow::about); aboutQtAct = new QAction(tr("About &Qt"), this); - connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt())); + connect(aboutQtAct, &QAction::triggered, qApp, &QApplication::aboutQt); aboutPluginsAct = new QAction(tr("About &Plugins"), this); - connect(aboutPluginsAct, SIGNAL(triggered()), this, SLOT(aboutPlugins())); + connect(aboutPluginsAct, &QAction::triggered, this, &MainWindow::aboutPlugins); } void MainWindow::createMenus() @@ -245,7 +242,8 @@ void MainWindow::createMenus() //! [4] void MainWindow::loadPlugins() { - foreach (QObject *plugin, QPluginLoader::staticInstances()) + const auto staticInstances = QPluginLoader::staticInstances(); + for (QObject *plugin : staticInstances) populateMenus(plugin); //! [4] //! [5] @@ -265,7 +263,8 @@ void MainWindow::loadPlugins() //! [5] //! [6] - foreach (QString fileName, pluginsDir.entryList(QDir::Files)) { + const auto entryList = pluginsDir.entryList(QDir::Files); + for (const QString &fileName : entryList) { QPluginLoader loader(pluginsDir.absoluteFilePath(fileName)); QObject *plugin = loader.instance(); if (plugin) { @@ -287,28 +286,28 @@ void MainWindow::loadPlugins() //! [10] void MainWindow::populateMenus(QObject *plugin) { - BrushInterface *iBrush = qobject_cast<BrushInterface *>(plugin); + auto iBrush = qobject_cast<BrushInterface *>(plugin); if (iBrush) - addToMenu(plugin, iBrush->brushes(), brushMenu, SLOT(changeBrush()), + addToMenu(plugin, iBrush->brushes(), brushMenu, &MainWindow::changeBrush, brushActionGroup); - ShapeInterface *iShape = qobject_cast<ShapeInterface *>(plugin); + auto iShape = qobject_cast<ShapeInterface *>(plugin); if (iShape) - addToMenu(plugin, iShape->shapes(), shapesMenu, SLOT(insertShape())); + addToMenu(plugin, iShape->shapes(), shapesMenu, &MainWindow::insertShape); - FilterInterface *iFilter = qobject_cast<FilterInterface *>(plugin); + auto iFilter = qobject_cast<FilterInterface *>(plugin); if (iFilter) - addToMenu(plugin, iFilter->filters(), filterMenu, SLOT(applyFilter())); + addToMenu(plugin, iFilter->filters(), filterMenu, &MainWindow::applyFilter); } //! [10] void MainWindow::addToMenu(QObject *plugin, const QStringList &texts, - QMenu *menu, const char *member, + QMenu *menu, Member member, QActionGroup *actionGroup) { - foreach (QString text, texts) { - QAction *action = new QAction(text, plugin); - connect(action, SIGNAL(triggered()), this, member); + for (const QString &text : texts) { + auto action = new QAction(text, plugin); + connect(action, &QAction::triggered, this, member); menu->addAction(action); if (actionGroup) { diff --git a/examples/widgets/tools/plugandpaint/app/mainwindow.h b/examples/widgets/tools/plugandpaint/app/mainwindow.h index 398759fecf..2b54264893 100644 --- a/examples/widgets/tools/plugandpaint/app/mainwindow.h +++ b/examples/widgets/tools/plugandpaint/app/mainwindow.h @@ -82,32 +82,34 @@ private slots: void aboutPlugins(); private: + typedef void (MainWindow::*Member)(); + void createActions(); void createMenus(); void loadPlugins(); void populateMenus(QObject *plugin); void addToMenu(QObject *plugin, const QStringList &texts, QMenu *menu, - const char *member, QActionGroup *actionGroup = 0); + Member member, QActionGroup *actionGroup = nullptr); - PaintArea *paintArea; - QScrollArea *scrollArea; + PaintArea *paintArea = nullptr; + QScrollArea *scrollArea = nullptr; QDir pluginsDir; QStringList pluginFileNames; - QMenu *fileMenu; - QMenu *brushMenu; - QMenu *shapesMenu; - QMenu *filterMenu; - QMenu *helpMenu; - QActionGroup *brushActionGroup; - QAction *openAct; - QAction *saveAsAct; - QAction *exitAct; - QAction *brushWidthAct; - QAction *brushColorAct; - QAction *aboutAct; - QAction *aboutQtAct; - QAction *aboutPluginsAct; + QMenu *fileMenu = nullptr; + QMenu *brushMenu = nullptr; + QMenu *shapesMenu = nullptr; + QMenu *filterMenu = nullptr; + QMenu *helpMenu = nullptr; + QActionGroup *brushActionGroup = nullptr; + QAction *openAct = nullptr; + QAction *saveAsAct = nullptr; + QAction *exitAct = nullptr; + QAction *brushWidthAct = nullptr; + QAction *brushColorAct = nullptr; + QAction *aboutAct = nullptr; + QAction *aboutQtAct = nullptr; + QAction *aboutPluginsAct = nullptr; }; #endif diff --git a/examples/widgets/tools/plugandpaint/app/paintarea.cpp b/examples/widgets/tools/plugandpaint/app/paintarea.cpp index 5d2170bfd4..4295e04cc0 100644 --- a/examples/widgets/tools/plugandpaint/app/paintarea.cpp +++ b/examples/widgets/tools/plugandpaint/app/paintarea.cpp @@ -52,16 +52,11 @@ #include "interfaces.h" #include "paintarea.h" -#include <QPainter> #include <QMouseEvent> +#include <QPainter> PaintArea::PaintArea(QWidget *parent) : - QWidget(parent), - theImage(500, 400, QImage::Format_RGB32), - color(Qt::blue), - thickness(3), - brushInterface(0), - lastPos(-1, -1) + QWidget(parent) { setAttribute(Qt::WA_StaticContents); setAttribute(Qt::WA_NoBackground); diff --git a/examples/widgets/tools/plugandpaint/app/paintarea.h b/examples/widgets/tools/plugandpaint/app/paintarea.h index 1c8ee1ee1b..1d1e6006c8 100644 --- a/examples/widgets/tools/plugandpaint/app/paintarea.h +++ b/examples/widgets/tools/plugandpaint/app/paintarea.h @@ -63,7 +63,7 @@ class PaintArea : public QWidget Q_OBJECT public: - PaintArea(QWidget *parent = 0); + PaintArea(QWidget *parent = nullptr); bool openImage(const QString &fileName); bool saveImage(const QString &fileName, const char *fileFormat); @@ -87,13 +87,13 @@ protected: private: void setupPainter(QPainter &painter); - QImage theImage; - QColor color; - int thickness; + QImage theImage = {500, 400, QImage::Format_RGB32}; + QColor color = Qt::blue; + int thickness = 3; - BrushInterface *brushInterface; + BrushInterface *brushInterface = nullptr; QString brush; - QPoint lastPos; + QPoint lastPos = {-1, -1}; QPainterPath pendingPath; }; diff --git a/examples/widgets/tools/plugandpaint/app/plugindialog.cpp b/examples/widgets/tools/plugandpaint/app/plugindialog.cpp index 00c2498bd5..af5828f67e 100644 --- a/examples/widgets/tools/plugandpaint/app/plugindialog.cpp +++ b/examples/widgets/tools/plugandpaint/app/plugindialog.cpp @@ -52,16 +52,15 @@ #include "interfaces.h" #include "plugindialog.h" -#include <QPluginLoader> -#include <QStringList> #include <QDir> - -#include <QLabel> #include <QGridLayout> +#include <QHeaderView> +#include <QLabel> +#include <QPluginLoader> #include <QPushButton> +#include <QStringList> #include <QTreeWidget> #include <QTreeWidgetItem> -#include <QHeaderView> PluginDialog::PluginDialog(const QString &path, const QStringList &fileNames, QWidget *parent) : @@ -77,7 +76,7 @@ PluginDialog::PluginDialog(const QString &path, const QStringList &fileNames, okButton->setDefault(true); - connect(okButton, SIGNAL(clicked()), this, SLOT(close())); + connect(okButton, &QAbstractButton::clicked, this, &QWidget::close); QGridLayout *mainLayout = new QGridLayout; mainLayout->setColumnStretch(0, 1); @@ -107,11 +106,12 @@ void PluginDialog::findPlugins(const QString &path, const QDir dir(path); - foreach (QObject *plugin, QPluginLoader::staticInstances()) + const auto staticInstances = QPluginLoader::staticInstances(); + for (QObject *plugin : staticInstances) populateTreeWidget(plugin, tr("%1 (Static Plugin)") .arg(plugin->metaObject()->className())); - foreach (QString fileName, fileNames) { + for (const QString &fileName : fileNames) { QPluginLoader loader(dir.absoluteFilePath(fileName)); QObject *plugin = loader.instance(); if (plugin) @@ -123,7 +123,7 @@ void PluginDialog::findPlugins(const QString &path, //! [1] void PluginDialog::populateTreeWidget(QObject *plugin, const QString &text) { - QTreeWidgetItem *pluginItem = new QTreeWidgetItem(treeWidget); + auto pluginItem = new QTreeWidgetItem(treeWidget); pluginItem->setText(0, text); treeWidget->setItemExpanded(pluginItem, true); @@ -132,16 +132,15 @@ void PluginDialog::populateTreeWidget(QObject *plugin, const QString &text) pluginItem->setFont(0, boldFont); if (plugin) { - BrushInterface *iBrush = qobject_cast<BrushInterface *>(plugin); + auto iBrush = qobject_cast<BrushInterface *>(plugin); if (iBrush) addItems(pluginItem, "BrushInterface", iBrush->brushes()); - ShapeInterface *iShape = qobject_cast<ShapeInterface *>(plugin); + auto iShape = qobject_cast<ShapeInterface *>(plugin); if (iShape) addItems(pluginItem, "ShapeInterface", iShape->shapes()); - FilterInterface *iFilter = - qobject_cast<FilterInterface *>(plugin); + auto iFilter = qobject_cast<FilterInterface *>(plugin); if (iFilter) addItems(pluginItem, "FilterInterface", iFilter->filters()); } @@ -152,14 +151,14 @@ void PluginDialog::addItems(QTreeWidgetItem *pluginItem, const char *interfaceName, const QStringList &features) { - QTreeWidgetItem *interfaceItem = new QTreeWidgetItem(pluginItem); + auto interfaceItem = new QTreeWidgetItem(pluginItem); interfaceItem->setText(0, interfaceName); interfaceItem->setIcon(0, interfaceIcon); - foreach (QString feature, features) { + for (QString feature : features) { if (feature.endsWith("...")) feature.chop(3); - QTreeWidgetItem *featureItem = new QTreeWidgetItem(interfaceItem); + auto featureItem = new QTreeWidgetItem(interfaceItem); featureItem->setText(0, feature); featureItem->setIcon(0, featureIcon); } diff --git a/examples/widgets/tools/plugandpaint/app/plugindialog.h b/examples/widgets/tools/plugandpaint/app/plugindialog.h index f8e5bcda24..b18b30e62c 100644 --- a/examples/widgets/tools/plugandpaint/app/plugindialog.h +++ b/examples/widgets/tools/plugandpaint/app/plugindialog.h @@ -68,7 +68,7 @@ class PluginDialog : public QDialog public: PluginDialog(const QString &path, const QStringList &fileNames, - QWidget *parent = 0); + QWidget *parent = nullptr); private: void findPlugins(const QString &path, const QStringList &fileNames); @@ -76,9 +76,9 @@ private: void addItems(QTreeWidgetItem *pluginItem, const char *interfaceName, const QStringList &features); - QLabel *label; - QTreeWidget *treeWidget; - QPushButton *okButton; + QLabel *label = nullptr; + QTreeWidget *treeWidget = nullptr; + QPushButton *okButton = nullptr; QIcon interfaceIcon; QIcon featureIcon; }; diff --git a/examples/widgets/tools/plugandpaint/plugins/basictools/basictoolsplugin.cpp b/examples/widgets/tools/plugandpaint/plugins/basictools/basictoolsplugin.cpp index 92620ddd8c..3b465565ba 100644 --- a/examples/widgets/tools/plugandpaint/plugins/basictools/basictoolsplugin.cpp +++ b/examples/widgets/tools/plugandpaint/plugins/basictools/basictoolsplugin.cpp @@ -48,18 +48,17 @@ ** ****************************************************************************/ +#include "basictoolsplugin.h" + +#include <QtMath> #include <QtWidgets> -#include <qmath.h> #include <stdlib.h> -#include "basictoolsplugin.h" - //! [0] QStringList BasicToolsPlugin::brushes() const { - return QStringList() << tr("Pencil") << tr("Air Brush") - << tr("Random Letters"); + return {tr("Pencil"), tr("Air Brush"), tr("Random Letters")}; } //! [0] @@ -132,7 +131,7 @@ QRect BasicToolsPlugin::mouseRelease(const QString & /* brush */, //! [5] QStringList BasicToolsPlugin::shapes() const { - return QStringList() << tr("Circle") << tr("Star") << tr("Text..."); + return {tr("Circle"), tr("Star"), tr("Text...")}; } //! [5] @@ -169,8 +168,7 @@ QPainterPath BasicToolsPlugin::generateShape(const QString &shape, //! [7] QStringList BasicToolsPlugin::filters() const { - return QStringList() << tr("Invert Pixels") << tr("Swap RGB") - << tr("Grayscale"); + return {tr("Invert Pixels"), tr("Swap RGB"), tr("Grayscale")}; } //! [7] @@ -187,7 +185,7 @@ QImage BasicToolsPlugin::filterImage(const QString &filter, const QImage &image, } else if (filter == tr("Grayscale")) { for (int y = 0; y < result.height(); ++y) { for (int x = 0; x < result.width(); ++x) { - int pixel = result.pixel(x, y); + QRgb pixel = result.pixel(x, y); int gray = qGray(pixel); int alpha = qAlpha(pixel); result.setPixel(x, y, qRgba(gray, gray, gray, alpha)); diff --git a/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafiltersplugin.cpp b/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafiltersplugin.cpp index 8f59afa759..48717e34f6 100644 --- a/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafiltersplugin.cpp +++ b/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafiltersplugin.cpp @@ -48,17 +48,17 @@ ** ****************************************************************************/ +#include "extrafiltersplugin.h" + #include <QtWidgets> #include <math.h> #include <stdlib.h> -#include "extrafiltersplugin.h" - QStringList ExtraFiltersPlugin::filters() const { - return QStringList() << tr("Flip Horizontally") << tr("Flip Vertically") - << tr("Smudge...") << tr("Threshold..."); + return {tr("Flip Horizontally"), tr("Flip Vertically"), + tr("Smudge..."), tr("Threshold...")}; } QImage ExtraFiltersPlugin::filterImage(const QString &filter, @@ -70,14 +70,14 @@ QImage ExtraFiltersPlugin::filterImage(const QString &filter, if (filter == tr("Flip Horizontally")) { for (int y = 0; y < original.height(); ++y) { for (int x = 0; x < original.width(); ++x) { - int pixel = original.pixel(original.width() - x - 1, y); + QRgb pixel = original.pixel(original.width() - x - 1, y); result.setPixel(x, y, pixel); } } } else if (filter == tr("Flip Vertically")) { for (int y = 0; y < original.height(); ++y) { for (int x = 0; x < original.width(); ++x) { - int pixel = original.pixel(x, original.height() - y - 1); + QRgb pixel = original.pixel(x, original.height() - y - 1); result.setPixel(x, y, pixel); } } @@ -90,11 +90,11 @@ QImage ExtraFiltersPlugin::filterImage(const QString &filter, for (int i = 0; i < numIters; ++i) { for (int y = 1; y < original.height() - 1; ++y) { for (int x = 1; x < original.width() - 1; ++x) { - int p1 = original.pixel(x, y); - int p2 = original.pixel(x, y + 1); - int p3 = original.pixel(x, y - 1); - int p4 = original.pixel(x + 1, y); - int p5 = original.pixel(x - 1, y); + QRgb p1 = original.pixel(x, y); + QRgb p2 = original.pixel(x, y + 1); + QRgb p3 = original.pixel(x, y - 1); + QRgb p4 = original.pixel(x + 1, y); + QRgb p5 = original.pixel(x - 1, y); int red = (qRed(p1) + qRed(p2) + qRed(p3) + qRed(p4) + qRed(p5)) / 5; @@ -119,7 +119,7 @@ QImage ExtraFiltersPlugin::filterImage(const QString &filter, int factor = 256 / threshold; for (int y = 0; y < original.height(); ++y) { for (int x = 0; x < original.width(); ++x) { - int pixel = original.pixel(x, y); + QRgb pixel = original.pixel(x, y); result.setPixel(x, y, qRgba(qRed(pixel) / factor * factor, qGreen(pixel) / factor * factor, qBlue(pixel) / factor * factor, diff --git a/examples/widgets/tutorials/notepad/images/bold.png b/examples/widgets/tutorials/notepad/images/bold.png Binary files differnew file mode 100644 index 0000000000..fe737cdb76 --- /dev/null +++ b/examples/widgets/tutorials/notepad/images/bold.png diff --git a/examples/widgets/tutorials/notepad/images/italic.png b/examples/widgets/tutorials/notepad/images/italic.png Binary files differnew file mode 100644 index 0000000000..337aac23a9 --- /dev/null +++ b/examples/widgets/tutorials/notepad/images/italic.png diff --git a/examples/widgets/tutorials/notepad/images/underline.png b/examples/widgets/tutorials/notepad/images/underline.png Binary files differnew file mode 100644 index 0000000000..437c45b3b1 --- /dev/null +++ b/examples/widgets/tutorials/notepad/images/underline.png diff --git a/examples/widgets/tutorials/notepad/notepad.cpp b/examples/widgets/tutorials/notepad/notepad.cpp index 44d8597cb7..99a1a52c2b 100644 --- a/examples/widgets/tutorials/notepad/notepad.cpp +++ b/examples/widgets/tutorials/notepad/notepad.cpp @@ -191,3 +191,27 @@ void Notepad::on_actionFont_triggered() if (fontSelected) ui->textEdit->setFont(font); } + +void Notepad::on_actionUnderline_triggered() +{ + ui->textEdit->setFontUnderline(ui->actionUnderline->isChecked()); +} + +void Notepad::on_actionItalic_triggered() +{ + ui->textEdit->setFontItalic(ui->actionItalic->isChecked()); +} + +void Notepad::on_actionBold_triggered() +{ + ui->actionBold->isChecked() ? ui->textEdit->setFontWeight(QFont::Bold) : + ui->textEdit->setFontWeight(QFont::Normal); +} + +void Notepad::on_actionAbout_triggered() +{ + QMessageBox::about(this, tr("About MDI"), + tr("The <b>Notepad</b> example demonstrates how to code a basic " + "text editor using QtWidgets")); + +} diff --git a/examples/widgets/tutorials/notepad/notepad.h b/examples/widgets/tutorials/notepad/notepad.h index f688df45ac..288ab4e373 100644 --- a/examples/widgets/tutorials/notepad/notepad.h +++ b/examples/widgets/tutorials/notepad/notepad.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2018 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. @@ -103,6 +103,14 @@ private slots: void on_actionFont_triggered(); + void on_actionBold_triggered(); + + void on_actionUnderline_triggered(); + + void on_actionItalic_triggered(); + + void on_actionAbout_triggered(); + //! [6] private: Ui::Notepad *ui; diff --git a/examples/widgets/tutorials/notepad/notepad.qrc b/examples/widgets/tutorials/notepad/notepad.qrc index ec11679f13..8c0486bc39 100644 --- a/examples/widgets/tutorials/notepad/notepad.qrc +++ b/examples/widgets/tutorials/notepad/notepad.qrc @@ -1,12 +1,5 @@ <RCC> <qresource prefix="/"> - <file>images/copy.png</file> - <file>images/create.png</file> - <file>images/cut.png</file> - <file>images/edit_redo.png</file> - <file>images/edit_undo.png</file> - <file>images/exit.png</file> - <file>images/font.png</file> <file>images/info.png</file> <file>images/new.png</file> <file>images/open.png</file> @@ -15,5 +8,15 @@ <file>images/print.png</file> <file>images/save.png</file> <file>images/save_as.png</file> + <file>images/exit.png</file> + <file>images/font.png</file> + <file>images/copy.png</file> + <file>images/create.png</file> + <file>images/cut.png</file> + <file>images/edit_redo.png</file> + <file>images/edit_undo.png</file> + <file>images/bold.png</file> + <file>images/italic.png</file> + <file>images/underline.png</file> </qresource> </RCC> diff --git a/examples/widgets/tutorials/notepad/notepad.ui b/examples/widgets/tutorials/notepad/notepad.ui index d197a95fe7..4b2a6a0675 100644 --- a/examples/widgets/tutorials/notepad/notepad.ui +++ b/examples/widgets/tutorials/notepad/notepad.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>524</width> - <height>300</height> + <width>800</width> + <height>400</height> </rect> </property> <property name="windowTitle"> @@ -25,7 +25,7 @@ <rect> <x>0</x> <y>0</y> - <width>524</width> + <width>800</width> <height>25</height> </rect> </property> @@ -74,7 +74,13 @@ <addaction name="actionPaste"/> <addaction name="actionUndo"/> <addaction name="actionRedo"/> + <addaction name="separator"/> <addaction name="actionFont"/> + <addaction name="actionBold"/> + <addaction name="actionItalic"/> + <addaction name="actionUnderline"/> + <addaction name="separator"/> + <addaction name="actionAbout"/> <addaction name="separator"/> <addaction name="actionExit"/> </widget> @@ -87,105 +93,224 @@ <property name="text"> <string>New</string> </property> + <property name="toolTip"> + <string>New text document</string> + </property> + <property name="shortcut"> + <string>Ctrl+N</string> + </property> </action> <action name="actionOpen"> <property name="icon"> - <iconset> + <iconset resource="notepad.qrc"> <normaloff>:/images/open.png</normaloff>:/images/open.png</iconset> </property> <property name="text"> <string>Open</string> </property> + <property name="toolTip"> + <string>Open file</string> + </property> + <property name="shortcut"> + <string>Ctrl+O</string> + </property> </action> <action name="actionSave"> <property name="icon"> - <iconset> + <iconset resource="notepad.qrc"> <normaloff>:/images/save.png</normaloff>:/images/save.png</iconset> </property> <property name="text"> <string>Save</string> </property> + <property name="toolTip"> + <string>Save file</string> + </property> + <property name="shortcut"> + <string>Ctrl+S</string> + </property> </action> <action name="actionSave_as"> <property name="icon"> - <iconset> + <iconset resource="notepad.qrc"> <normaloff>:/images/save_as.png</normaloff>:/images/save_as.png</iconset> </property> <property name="text"> <string>Save as</string> </property> + <property name="toolTip"> + <string>Save file as</string> + </property> + <property name="shortcut"> + <string>Alt+S</string> + </property> </action> <action name="actionPrint"> <property name="icon"> - <iconset> + <iconset resource="notepad.qrc"> <normaloff>:/images/print.png</normaloff>:/images/print.png</iconset> </property> <property name="text"> <string>Print</string> </property> + <property name="toolTip"> + <string>Print file</string> + </property> + <property name="shortcut"> + <string>Ctrl+P</string> + </property> </action> <action name="actionExit"> <property name="icon"> - <iconset> + <iconset theme="exit.png" resource="notepad.qrc"> <normaloff>:/images/exit.png</normaloff>:/images/exit.png</iconset> </property> <property name="text"> <string>Exit</string> </property> + <property name="toolTip"> + <string>Exit notepad</string> + </property> + <property name="shortcut"> + </property> </action> <action name="actionCopy"> <property name="icon"> - <iconset> + <iconset resource="notepad.qrc"> <normaloff>:/images/copy.png</normaloff>:/images/copy.png</iconset> </property> <property name="text"> <string>Copy</string> </property> + <property name="shortcut"> + <string>Ctrl+C</string> + </property> </action> <action name="actionCut"> <property name="icon"> - <iconset> + <iconset resource="notepad.qrc"> <normaloff>:/images/cut.png</normaloff>:/images/cut.png</iconset> </property> <property name="text"> <string>Cut</string> </property> + <property name="shortcut"> + <string>Ctrl+X</string> + </property> </action> <action name="actionPaste"> <property name="icon"> - <iconset> + <iconset resource="notepad.qrc"> <normaloff>:/images/paste.png</normaloff>:/images/paste.png</iconset> </property> <property name="text"> <string>Paste</string> </property> + <property name="shortcut"> + <string>Ctrl+V</string> + </property> </action> <action name="actionUndo"> <property name="icon"> - <iconset> + <iconset resource="notepad.qrc"> <normaloff>:/images/edit_undo.png</normaloff>:/images/edit_undo.png</iconset> </property> <property name="text"> <string>Undo</string> </property> + <property name="shortcut"> + <string>Ctrl+Z</string> + </property> </action> <action name="actionRedo"> <property name="icon"> - <iconset> + <iconset resource="notepad.qrc"> <normaloff>:/images/edit_redo.png</normaloff>:/images/edit_redo.png</iconset> </property> <property name="text"> <string>Redo</string> </property> + <property name="shortcut"> + <string>Ctrl+Y</string> + </property> </action> <action name="actionFont"> <property name="icon"> - <iconset> + <iconset resource="notepad.qrc"> <normaloff>:/images/font.png</normaloff>:/images/font.png</iconset> </property> <property name="text"> <string>Font</string> </property> + <property name="shortcut"> + <string>Ctrl+F</string> + </property> + </action> + <action name="actionItalic"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="icon"> + <iconset resource="notepad.qrc"> + <normaloff>:/images/italic.png</normaloff>:/images/italic.png</iconset> + </property> + <property name="text"> + <string>Italic</string> + </property> + <property name="toolTip"> + <string>Italic font</string> + </property> + <property name="shortcut"> + <string>Ctrl+I</string> + </property> + </action> + <action name="actionBold"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="icon"> + <iconset resource="notepad.qrc"> + <normaloff>:/images/bold.png</normaloff>:/images/bold.png</iconset> + </property> + <property name="text"> + <string>actionBold</string> + </property> + <property name="toolTip"> + <string>Bold</string> + </property> + <property name="shortcut"> + <string>Ctrl+B</string> + </property> + </action> + <action name="actionUnderline"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="icon"> + <iconset resource="notepad.qrc"> + <normaloff>:/images/underline.png</normaloff>:/images/underline.png</iconset> + </property> + <property name="text"> + <string>Underline</string> + </property> + <property name="toolTip"> + <string>Underline</string> + </property> + <property name="shortcut"> + <string>Ctrl+U</string> + </property> + </action> + <action name="actionAbout"> + <property name="icon"> + <iconset resource="notepad.qrc"> + <normaloff>:/images/info.png</normaloff>:/images/info.png</iconset> + </property> + <property name="text"> + <string>About</string> + </property> + <property name="toolTip"> + <string>About Notepad</string> + </property> </action> </widget> <layoutdefault spacing="6" margin="11"/> diff --git a/examples/widgets/widgets.pro b/examples/widgets/widgets.pro index cef4936d32..f9d863b69e 100644 --- a/examples/widgets/widgets.pro +++ b/examples/widgets/widgets.pro @@ -26,5 +26,5 @@ qtHaveModule(gui):qtConfig(opengl): \ SUBDIRS += windowcontainer contains(DEFINES, QT_NO_CURSOR): SUBDIRS -= mainwindows -contains(DEFINES, QT_NO_DRAGANDDROP): SUBDIRS -= draganddrop +!qtConfig(draganddrop): SUBDIRS -= draganddrop mac:SUBDIRS += mac |