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:
parent
b5a1e7ac5c
commit
e81383eb09
@ -21,5 +21,7 @@ contains(QT_BUILD_PARTS, tests) {
|
||||
textdocument-listitems \
|
||||
textdocument-listitemstyles \
|
||||
textdocument-lists \
|
||||
textdocument-printing
|
||||
textdocument-printing \
|
||||
textdocument-resources \
|
||||
textdocument-selections
|
||||
}
|
||||
|
@ -47,11 +47,10 @@
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtGui>
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user