summaryrefslogtreecommitdiffstats
path: root/examples/widgets/richtext/textedit/main.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-08-25 14:19:37 +0200
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-08-31 19:55:33 +0000
commitfe1ea010b946518803ca1cec1332945c26be83af (patch)
tree3babd2aa71817252280ed4011a88ccac14ae407e /examples/widgets/richtext/textedit/main.cpp
parentfb60f225e67db6c548fc2c5dfbe172251993daba (diff)
Polish rich text example.
- Introduce Qt 5 signals & slot syntax. - Use mime types in the file dialogs. - Streamline the code creating the actions. - Introduce QCommandLineParser. - Query the available size when determining the initial size instead of using hard-coded values for High-DPI screens. Change-Id: Ifc84a41ed55a4a674b6eafdb6120ac42441405b6 Reviewed-by: Topi Reiniƶ <topi.reinio@digia.com>
Diffstat (limited to 'examples/widgets/richtext/textedit/main.cpp')
-rw-r--r--examples/widgets/richtext/textedit/main.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/examples/widgets/richtext/textedit/main.cpp b/examples/widgets/richtext/textedit/main.cpp
index 4dda7e6c75..1de6d994e6 100644
--- a/examples/widgets/richtext/textedit/main.cpp
+++ b/examples/widgets/richtext/textedit/main.cpp
@@ -32,15 +32,37 @@
****************************************************************************/
#include "textedit.h"
+
#include <QApplication>
+#include <QDesktopWidget>
+#include <QCommandLineParser>
+#include <QCommandLineOption>
int main(int argc, char *argv[])
{
Q_INIT_RESOURCE(textedit);
QApplication a(argc, argv);
+ QCoreApplication::setOrganizationName("QtProject");
+ QCoreApplication::setApplicationName("Rich Text");
+ QCoreApplication::setApplicationVersion(QT_VERSION_STR);
+ QCommandLineParser parser;
+ parser.setApplicationDescription(QCoreApplication::applicationName());
+ parser.addHelpOption();
+ parser.addVersionOption();
+ parser.addPositionalArgument("file", "The file to open.");
+ parser.process(a);
+
TextEdit mw;
- mw.resize(700, 800);
+
+ const QRect availableGeometry = QApplication::desktop()->availableGeometry(&mw);
+ mw.resize(availableGeometry.width() / 2, (availableGeometry.height() * 2) / 3);
+ mw.move((availableGeometry.width() - mw.width()) / 2,
+ (availableGeometry.height() - mw.height()) / 2);
+
+ if (!mw.load(parser.positionalArguments().value(0, QLatin1String(":/example.html"))))
+ mw.fileNew();
+
mw.show();
return a.exec();
}