Doc: Make Qt Gui snippets compilable - textdocument-selections

Task-number: QTBUG-81486
Change-Id: I467ca4d5ecd33f84e44b456a9559748ffd6cc53c
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
This commit is contained in:
Nico Vertriest 2020-08-05 11:49:23 +02:00 committed by Paul Wicking
parent b5a1e7ac5c
commit e81383eb09
5 changed files with 21 additions and 18 deletions

View File

@ -21,5 +21,7 @@ contains(QT_BUILD_PARTS, tests) {
textdocument-listitems \
textdocument-listitemstyles \
textdocument-lists \
textdocument-printing
textdocument-printing \
textdocument-resources \
textdocument-selections
}

View File

@ -47,11 +47,10 @@
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QtGui>
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);

View File

@ -47,11 +47,10 @@
** $QT_END_LICENSE$
**
****************************************************************************/
#include "mainwindow.h"
#include <QtWidgets>
#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);

View File

@ -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;
};

View File

@ -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