Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#include "qpixeltool.h"
5
6#include <qapplication.h>
7#include <qcommandlineparser.h>
8#include <qcommandlineoption.h>
9#include <qfileinfo.h>
10
11QT_USE_NAMESPACE
12
13using namespace Qt::StringLiterals;
14
15int main(int argc, char **argv)
16{
17 QApplication app(argc, argv);
18 QCoreApplication::setApplicationName("PixelTool"_L1);
19 QCoreApplication::setApplicationVersion(QLatin1StringView(qVersion()));
20 QCoreApplication::setOrganizationName("QtProject"_L1);
21
22 QCommandLineParser parser;
23 parser.addHelpOption();
24 parser.addVersionOption();
25 parser.addPositionalArgument("preview"_L1,
26 "The preview image to show."_L1);
27
28 parser.process(app);
29
30 QPixelTool pixelTool;
31
32 if (!parser.positionalArguments().isEmpty()) {
33 const QString previewImageFileName = parser.positionalArguments().constFirst();
34 if (QFileInfo::exists(previewImageFileName)) {
35 QImage previewImage(previewImageFileName);
36 if (!previewImage.size().isEmpty())
37 pixelTool.setPreviewImage(previewImage);
38 }
39 }
40
41 pixelTool.show();
42
43 QObject::connect(&app, &QApplication::lastWindowClosed,
44 &app, &QCoreApplication::quit);
45
46 return QCoreApplication::exec();
47}
int main(int argc, char *argv[])
[2]
Definition buffer.cpp:77
The QCommandLineParser class provides a means for handling the command line options.