From e81383eb0994a37b9489a2aebd0459e161dbeed2 Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Wed, 5 Aug 2020 11:49:23 +0200 Subject: [PATCH] Doc: Make Qt Gui snippets compilable - textdocument-selections MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-81486 Change-Id: I467ca4d5ecd33f84e44b456a9559748ffd6cc53c Reviewed-by: Topi Reiniƶ --- src/gui/doc/snippets/snippets.pro | 4 +++- .../doc/snippets/textdocument-selections/main.cpp | 5 ++--- .../textdocument-selections/mainwindow.cpp | 6 +----- .../snippets/textdocument-selections/mainwindow.h | 10 +++++----- .../textdocument-selections.pro | 14 ++++++++++---- 5 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/gui/doc/snippets/snippets.pro b/src/gui/doc/snippets/snippets.pro index 423d898932..d9abd0f5e1 100644 --- a/src/gui/doc/snippets/snippets.pro +++ b/src/gui/doc/snippets/snippets.pro @@ -21,5 +21,7 @@ contains(QT_BUILD_PARTS, tests) { textdocument-listitems \ textdocument-listitemstyles \ textdocument-lists \ - textdocument-printing + textdocument-printing \ + textdocument-resources \ + textdocument-selections } diff --git a/src/gui/doc/snippets/textdocument-selections/main.cpp b/src/gui/doc/snippets/textdocument-selections/main.cpp index 60afcac7b5..cb8158adf9 100644 --- a/src/gui/doc/snippets/textdocument-selections/main.cpp +++ b/src/gui/doc/snippets/textdocument-selections/main.cpp @@ -47,11 +47,10 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - -#include - #include "mainwindow.h" +#include + int main(int argc, char *argv[]) { QApplication app(argc, argv); diff --git a/src/gui/doc/snippets/textdocument-selections/mainwindow.cpp b/src/gui/doc/snippets/textdocument-selections/mainwindow.cpp index 9253e87670..3e491151bc 100644 --- a/src/gui/doc/snippets/textdocument-selections/mainwindow.cpp +++ b/src/gui/doc/snippets/textdocument-selections/mainwindow.cpp @@ -47,11 +47,10 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +#include "mainwindow.h" #include -#include "mainwindow.h" - MainWindow::MainWindow() { QMenu *fileMenu = new QMenu(tr("&File")); @@ -151,7 +150,6 @@ void MainWindow::pasteSelection() void MainWindow::selectWord() { QTextCursor cursor = editor->textCursor(); - QTextBlock block = cursor.block(); //! [0] cursor.beginEditBlock(); @@ -168,7 +166,6 @@ void MainWindow::selectWord() void MainWindow::selectLine() { QTextCursor cursor = editor->textCursor(); - QTextBlock block = cursor.block(); cursor.beginEditBlock(); cursor.movePosition(QTextCursor::StartOfLine); @@ -181,7 +178,6 @@ void MainWindow::selectLine() void MainWindow::selectBlock() { QTextCursor cursor = editor->textCursor(); - QTextBlock block = cursor.block(); cursor.beginEditBlock(); cursor.movePosition(QTextCursor::StartOfBlock); diff --git a/src/gui/doc/snippets/textdocument-selections/mainwindow.h b/src/gui/doc/snippets/textdocument-selections/mainwindow.h index 7b75b13e82..8327a55877 100644 --- a/src/gui/doc/snippets/textdocument-selections/mainwindow.h +++ b/src/gui/doc/snippets/textdocument-selections/mainwindow.h @@ -77,12 +77,12 @@ public slots: void updateMenus(); private: - QAction *cutAction; - QAction *copyAction; - QAction *pasteAction; + QAction *cutAction = nullptr; + QAction *copyAction = nullptr; + QAction *pasteAction = nullptr; QString currentFile; - QTextEdit *editor; - QTextDocument *document; + QTextEdit *editor = nullptr; + QTextDocument *document = nullptr; QTextDocumentFragment selection; }; diff --git a/src/gui/doc/snippets/textdocument-selections/textdocument-selections.pro b/src/gui/doc/snippets/textdocument-selections/textdocument-selections.pro index 253c452723..79e36d3881 100644 --- a/src/gui/doc/snippets/textdocument-selections/textdocument-selections.pro +++ b/src/gui/doc/snippets/textdocument-selections/textdocument-selections.pro @@ -1,4 +1,10 @@ -QT += xml -HEADERS = mainwindow.h -SOURCES = main.cpp \ - mainwindow.cpp +TEMPLATE = lib +TARGET = textdocument-selections +QT += core gui widgets + +HEADERS = \ + mainwindow.h + +SOURCES = \ + main.cpp \ + mainwindow.cpp