### Define examples install path Source: https://doc.qt.io/archives/qt-5.15/qtgui-qdocconf.html Specifies the directory where examples will be installed relative to the parent examples directory. ```qdocconf examplesinstallpath = gui ``` -------------------------------- ### Configure project file for Quick Items example Source: https://doc.qt.io/archives/qt-5.15/qtquick3d-quickitems-quickitems-pro.html Defines the project dependencies, installation path, and source files for the Quick Items example. ```qmake QT += quick quick3d target.path = $$[QT_INSTALL_EXAMPLES]/quick3d/quickitems INSTALLS += target SOURCES += \ main.cpp RESOURCES += \ qml.qrc OTHER_FILES += \ doc/src/*.* ``` -------------------------------- ### Specify example install path Source: https://doc.qt.io/archives/qt-5.15/12-0-qdoc-commands-miscellaneous.html Override the default installation path for an example by using the \meta command with the installpath attribute. ```qdoc / *! \example helloworld \title Hello World Example \meta {installpath} {tutorials} * / ``` -------------------------------- ### Main entry point for the Waterpump example Source: https://doc.qt.io/archives/qt-5.15/qtopcua-waterpump-waterpump-qml-main-cpp.html Initializes the application, locates and starts the simulation server process, and loads the main QML file. ```cpp /**************************************************************************** ** ** Copyright (C) 2018 basysKom GmbH, opensource@basyskom.com ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the QtOpcUa module. ** ** $QT_BEGIN_LICENSE:BSD$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** BSD License Usage ** Alternatively, you may use this file under the terms of the BSD license ** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include #include #include #include #include int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QString serverExePath; #ifdef Q_OS_WIN #ifdef QT_DEBUG serverExePath = app.applicationDirPath().append("/../../simulationserver/debug/simulationserver.exe"); #else serverExePath = app.applicationDirPath().append("/../../simulationserver/release/simulationserver.exe"); #endif #elif defined(Q_OS_MACOS) serverExePath = app.applicationDirPath().append("/../../../../simulationserver/simulationserver.app/Contents/MacOS/simulationserver"); #else serverExePath = app.applicationDirPath().append("/../simulationserver/simulationserver"); #endif if (!QFile::exists(serverExePath)) { qWarning() << "Could not find server executable:" << serverExePath; return EXIT_FAILURE; } QProcess serverProcess; serverProcess.start(serverExePath); if (!serverProcess.waitForStarted()) { qWarning() << "Could not start server:" << serverProcess.errorString(); return EXIT_FAILURE; } QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); if (engine.rootObjects().isEmpty()) return EXIT_FAILURE; const int exitCode = QCoreApplication::exec(); if (serverProcess.state() == QProcess::Running) { #ifndef Q_OS_WIN serverProcess.terminate(); #else serverProcess.kill(); #endif serverProcess.waitForFinished(); } return exitCode; } ``` -------------------------------- ### Configure Example Directories Source: https://doc.qt.io/archives/qt-5.15/qtgui-qdocconf.html Adds directories containing example source code for documentation. ```text exampledirs += ../../../examples/gui \ snippets ``` -------------------------------- ### Documenting an example with \example Source: https://doc.qt.io/archives/qt-5.15/13-qdoc-commands-topics.html Defines an example path relative to the exampledirs configuration variable. ```qdoc / *! \example widgets/imageviewer \title ImageViewer Example \subtitle The example shows how to combine QLabel and QScrollArea to display an image. ... * / ``` -------------------------------- ### Define example directories and files Source: https://doc.qt.io/archives/qt-5.15/22-qdoc-configuration-generalvariables.html Sets the search paths for example source files and explicitly lists specific example files. ```qdoc exampledirs = $QTDIR/doc/src \ $QTDIR/examples \ $QTDIR \ $QTDIR/qmake/examples examples = $QTDIR/examples/widgets/analogclock/analogclock.cpp ``` -------------------------------- ### Build and install Qt Source: https://doc.qt.io/archives/qt-5.15/android-building.html Compile the source code using make and install the resulting binaries. ```bash make -j$(nproc) ``` ```bash make install ``` -------------------------------- ### Install Qt Source: https://doc.qt.io/archives/qt-5.15/integrity-building-qt-for-imx6quad-board.html Install the built binaries if a custom prefix was not specified during configuration. ```bash cd make install ``` -------------------------------- ### Build and Install Qt Source: https://doc.qt.io/archives/qt-5.15/android-building.html Compiles the configured source code and installs the resulting binaries. ```batch mingw32-make.exe -j ``` ```batch mingw32-make.exe install ``` -------------------------------- ### Build and Install Qt 5 Source: https://doc.qt.io/archives/qt-5.15/vxworks.html Standard commands to compile and install the Qt 5 framework. ```bash make -j make install ``` -------------------------------- ### start() Source: https://doc.qt.io/archives/qt-5.15/qbluetoothdevicediscoveryagent.html Starts the Bluetooth device discovery process using default methods. ```APIDOC ## void start() ### Description Starts the Bluetooth device discovery process using the default discovery methods. ``` -------------------------------- ### bool QHelpEngineCore::setupData() Source: https://doc.qt.io/archives/qt-5.15/qhelpenginecore.html Initializes the help engine by processing the collection file. ```APIDOC ## bool QHelpEngineCore::setupData() ### Description Sets up the help engine by processing the information found in the collection file and returns true if successful; otherwise returns false. ``` -------------------------------- ### Set example directories Source: https://doc.qt.io/archives/qt-5.15/qdoc-minimum-qdocconf.html Defines the directory containing example source code files. ```qdocconf exampledirs = . ``` -------------------------------- ### start Source: https://doc.qt.io/archives/qt-5.15/qknxnetipserverdiscoveryagent.html Starts the server discovery process using various configuration options. ```APIDOC ## void start(QKnxNetIpServerDiscoveryAgent::InterfaceTypes types) ### Description Starts the server discovery agent using the specified network interface types. ### Parameters - **types** (QKnxNetIpServerDiscoveryAgent::InterfaceTypes) - The list of interface types to use for discovery. ``` -------------------------------- ### Initialize the Application Source: https://doc.qt.io/archives/qt-5.15/qtcore-ipc-sharedmemory-example.html The main entry point creates the QApplication and displays the Dialog instance. ```cpp int main(int argc, char *argv[]) { QApplication application(argc, argv); Dialog dialog; dialog.show(); return application.exec(); } ``` -------------------------------- ### Start Data Generation Source: https://doc.qt.io/archives/qt-5.15/qtdatavisualization-itemmodel-example.html Trigger the generator's start method after application setup. ```cpp generator.start(); ``` -------------------------------- ### Query specific installation path Source: https://doc.qt.io/archives/qt-5.15/qmake-environment-reference.html Example of querying the installation prefix for the current qmake version. ```bash qmake -query "QT_INSTALL_PREFIX" ``` -------------------------------- ### Main entry point for MQTT Subscriptions example Source: https://doc.qt.io/archives/qt-5.15/qtmqtt-subscriptions-main-cpp.html Initializes the QApplication and displays the MainWindow for the MQTT Subscriptions application. ```cpp /**************************************************************************** ** ** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** BSD License Usage ** Alternatively, you may use this file under the terms of the BSD license ** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include "mainwindow.h" #include int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); } ``` -------------------------------- ### Linker error example Source: https://doc.qt.io/archives/qt-5.15/windows-issues.html Example of a linker error caused by installing Qt in a directory path containing spaces. ```text c:\program.obj not found ``` -------------------------------- ### QUICK_TEST_MAIN_WITH_SETUP(name, QuickTestSetupClass) Source: https://doc.qt.io/archives/qt-5.15/qquicktest.html Macro to define the entry point for a Qt Quick Test application with custom setup logic. ```APIDOC ## QUICK_TEST_MAIN_WITH_SETUP(name, QuickTestSetupClass) ### Description Sets up the entry point for a Qt Quick Test application, allowing for additional setup code to execute before running the QML test via a QObject-derived class. ### Parameters - **name** (identifier) - Required - Unique identifier for the test suite. - **QuickTestSetupClass** (class) - Required - A pointer to a QObject-derived class containing setup logic. ``` -------------------------------- ### Define idle state transitions Source: https://doc.qt.io/archives/qt-5.15/qtscxml-sudoku-example.html The idle state handles start and setup events, where setup initializes the game state and triggers a restart. ```xml ``` -------------------------------- ### QLinearGradient::start Source: https://doc.qt.io/archives/qt-5.15/qlineargradient.html Methods to get and set the start point of the linear gradient. ```APIDOC ## QPointF start() const ## void setStart(const QPointF &start) ## void setStart(qreal x, qreal y) ### Description Returns or sets the start point of the linear gradient in logical coordinates. ``` -------------------------------- ### Initialize Application Main Entry Point Source: https://doc.qt.io/archives/qt-5.15/qtscxml-sudoku-example.html Sets up the QApplication, initializes the Sudoku state machine, and displays the main window. ```cpp #include "mainwindow.h" #include "sudoku.h" #include int main(int argc, char **argv) { QApplication app(argc, argv); Sudoku machine; MainWindow mainWindow(&machine); machine.start(); mainWindow.show(); return app.exec(); } ``` -------------------------------- ### Initialize and start audio playback Source: https://doc.qt.io/archives/qt-5.15/qaudiooutput.html Configures the audio format and device, then starts playback from a QFile. ```cpp QFile sourceFile; // class member. QAudioOutput* audio; // class member. { sourceFile.setFileName("/tmp/test.raw"); sourceFile.open(QIODevice::ReadOnly); QAudioFormat format; // Set up the format, eg. format.setSampleRate(8000); format.setChannelCount(1); format.setSampleSize(8); format.setCodec("audio/pcm"); format.setByteOrder(QAudioFormat::LittleEndian); format.setSampleType(QAudioFormat::UnSignedInt); QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice()); if (!info.isFormatSupported(format)) { qWarning() << "Raw audio format not supported by backend, cannot play audio."; return; } audio = new QAudioOutput(format, this); connect(audio, SIGNAL(stateChanged(QAudio::State)), this, SLOT(handleStateChanged(QAudio::State))); audio->start(&sourceFile); } ``` -------------------------------- ### Initialize Application and Window Source: https://doc.qt.io/archives/qt-5.15/qtgui-openglwindow-example.html Set up the QGuiApplication and configure the surface format for the OpenGL window. ```cpp int main(int argc, char **argv) { QGuiApplication app(argc, argv); QSurfaceFormat format; format.setSamples(16); TriangleWindow window; window.setFormat(format); window.resize(640, 480); window.show(); window.setAnimating(true); return app.exec(); } ``` -------------------------------- ### Start the client application Source: https://doc.qt.io/archives/qt-5.15/qtvirtualkeyboard-deployment-guide.html Command to launch the Line Edits example as a Wayland client. ```bash ./lineedits -platform wayland ``` -------------------------------- ### Setup Script Engine and Translator Source: https://doc.qt.io/archives/qt-5.15/qtscript-script-helloscript-example.html Configures the QScriptEngine and installs translation functions for internationalization. ```cpp QApplication app(argc, argv); QScriptEngine engine; QTranslator translator; translator.load("helloscript_la"); app.installTranslator(&translator); engine.installTranslatorFunctions(); ``` -------------------------------- ### Implement main application entry point Source: https://doc.qt.io/archives/qt-5.15/remoteobjects-example-static-source.html Initialize the node, acquire the replica, and pass it to the client object. ```cpp #include #include "client.h" int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QSharedPointer ptr; // shared pointer to hold source replica QRemoteObjectNode repNode; // create remote object node repNode.connectToNode(QUrl(QStringLiteral("local:switch"))); // connect with remote host node ptr.reset(repNode.acquire()); // acquire replica of source from host node Client rswitch(ptr); // create client switch object and pass reference of replica to it return a.exec(); } ``` -------------------------------- ### Setup UI Source: https://doc.qt.io/archives/qt-5.15/qtwidgets-tutorials-notepad-example.html Initializes the user interface components. ```cpp ui->setupUi(this); ``` -------------------------------- ### Run compliance tests in fuzzingclient mode Source: https://doc.qt.io/archives/qt-5.15/qtwebsockets-testing.html Build the echoserver example and start the Autobahn fuzzingclient. ```bash cd your_build_dir/examples/websockets/echoserver qmake your_src_dir/examples/websockets/echoserver/echoserver.pro make ./echoserver -p 9001 ``` ```bash cd ~ wstest -m fuzzingclient ``` -------------------------------- ### Using \brief for a non-boolean property Source: https://doc.qt.io/archives/qt-5.15/11-qdoc-commands-specialcontent.html Example of using \brief for a property, which must start with 'The'. ```qdoc / *! \property QWidget::geometry \brief The geometry of the widget relative to its parent and excluding the window frame. When changing the geometry, the widget, if visible, receives a move event (moveEvent()) and/or a resize event (resizeEvent()) immediately. ... \sa frameGeometry(), rect(), ... * / ``` -------------------------------- ### Main Application Entry Point Source: https://doc.qt.io/archives/qt-5.15/qtwidgets-draganddrop-dropsite-example.html Initializes the QApplication and displays the DropSiteWindow. ```cpp int main(int argc, char *argv[]) { QApplication app(argc, argv); DropSiteWindow window; window.show(); return app.exec(); } ``` -------------------------------- ### QOpcUaGdsClient Usage Source: https://doc.qt.io/archives/qt-5.15/qopcuagdsclient.html Example demonstrating how to initialize a GDS client, handle authentication, and start the registration process. ```APIDOC ## QOpcUaGdsClient Usage ### Description This example shows how to configure a QOpcUaGdsClient instance, provide authentication credentials via the authenticationRequired signal, and initiate the registration process. ### Code Example ```cpp QOpcUaGdsClient c; // In case the credentials are needed QObject::connect(&c, &QOpcUaGdsClient::authenticationRequired, [&](QOpcUaAuthenticationInformation &authInfo) { authInfo.setUsernameAuthentication("root", "secret"); }); // Await success QObject::connect(&c, &QOpcUaGdsClient::applicationRegistered, [&]() { qDebug() << "Application" << c.applicationId() << "registered"; }); c.setBackend(...); c.setEndpoint(...); c.setApplicationIdentity(...); c.setPkiConfiguration(...); c.setApplicationRecord(...); c.setCertificateSigningRequestPresets(...); c.start(); ``` ``` -------------------------------- ### Using \brief for a boolean property Source: https://doc.qt.io/archives/qt-5.15/11-qdoc-commands-specialcontent.html Example of using \brief for a boolean property, which must start with 'Whether'. ```qdoc / *! \property QWidget::isActiveWindow \brief Whether this widget's window is the active window. The active window is the window that contains the widget that has keyboard focus. When popup windows are visible, this property is \c true for both the active window \e and the popup. \sa activateWindow(), QApplication::activeWindow() * / ``` -------------------------------- ### Main Function Setup Source: https://doc.qt.io/archives/qt-5.15/qtwebengine-webenginewidgets-printme-example.html Initializes the QWebEngineView and connects keyboard shortcuts to the PrintHandler for print and print preview functionality. ```cpp QWebEngineView view; view.setUrl(QUrl(QStringLiteral("qrc:/index.html"))); view.resize(1024, 750); view.show(); PrintHandler handler; handler.setPage(view.page()); auto printPreviewShortCut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_P), &view); auto printShortCut = new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_P), &view); QObject::connect(printPreviewShortCut, &QShortcut::activated, &handler, &PrintHandler::printPreview); QObject::connect(printShortCut, &QShortcut::activated, &handler, &PrintHandler::print); ``` -------------------------------- ### Prepare variables for status reporting Source: https://doc.qt.io/archives/qt-5.15/qstring.html Example setup for using QStringView with arg() to construct progress status strings. ```cpp int i; // current file's number int total; // number of files to process QStringView fileName; // current file's name ``` -------------------------------- ### Define a Qt Quick Test Entry Point with Setup Source: https://doc.qt.io/archives/qt-5.15/qquicktest.html Use QUICK_TEST_MAIN_WITH_SETUP to execute custom setup code, such as configuring the QQmlEngine, before running QML tests. ```cpp // tst_mytest.cpp #include #include #include class Setup : public QObject { Q_OBJECT public: Setup() {} public slots: void qmlEngineAvailable(QQmlEngine *engine) { engine->rootContext()->setContextProperty("myContextProperty", QVariant(true)); } }; QUICK_TEST_MAIN_WITH_SETUP(mytest, Setup) #include "tst_mytest.moc" ``` -------------------------------- ### Configure project file for Principled Material Source: https://doc.qt.io/archives/qt-5.15/qtquick3d-principledmaterial-principledmaterial-pro.html Defines the project modules, installation path, and source files required for the example. ```qmake QT += quick quick3d target.path = $$[QT_INSTALL_EXAMPLES]/quick3d/principledmaterial INSTALLS += target SOURCES += \ main.cpp RESOURCES += \ qml.qrc \ materials.qrc OTHER_FILES += \ doc/src/*.* ``` -------------------------------- ### Initialize QSettings with Organization and Application Source: https://doc.qt.io/archives/qt-5.15/qsettings.html Demonstrates the equivalence between a single-line constructor and setting global application metadata. ```cpp QSettings settings("Moose Soft", "Facturo-Pro"); ``` ```cpp QCoreApplication::setOrganizationName("Moose Soft"); QCoreApplication::setApplicationName("Facturo-Pro"); QSettings settings; ``` -------------------------------- ### Complete minimal Q3DSurface example Source: https://doc.qt.io/archives/qt-5.15/q3dsurface.html A full implementation showing the setup, data population, and display of a 3D surface graph. ```cpp #include using namespace QtDataVisualization; int main(int argc, char **argv) { QGuiApplication app(argc, argv); Q3DSurface surface; surface.setFlags(surface.flags() ^ Qt::FramelessWindowHint); QSurfaceDataArray *data = new QSurfaceDataArray; QSurfaceDataRow *dataRow1 = new QSurfaceDataRow; QSurfaceDataRow *dataRow2 = new QSurfaceDataRow; *dataRow1 << QVector3D(0.0f, 0.1f, 0.5f) << QVector3D(1.0f, 0.5f, 0.5f); *dataRow2 << QVector3D(0.0f, 1.8f, 1.0f) << QVector3D(1.0f, 1.2f, 1.0f); *data << dataRow1 << dataRow2; QSurface3DSeries *series = new QSurface3DSeries; series->dataProxy()->resetArray(data); surface.addSeries(series); surface.show(); return app.exec(); } ``` -------------------------------- ### Configure Custom Materials project file Source: https://doc.qt.io/archives/qt-5.15/qtquick3d-custommaterial-custommaterial-pro.html Defines the project modules, installation path, and source files for the Custom Materials example. ```qmake QT += quick quick3d target.path = $$[QT_INSTALL_EXAMPLES]/quick3d/custommaterial INSTALLS += target SOURCES += \ main.cpp RESOURCES += \ qml.qrc \ materials.qrc OTHER_FILES += \ doc/src/*.* ``` -------------------------------- ### Initialize Application and Parse Arguments Source: https://doc.qt.io/archives/qt-5.15/qtwebengine-webenginewidgets-html2pdf-example.html Sets up the application metadata and command line parser to handle input URL and output file path arguments. Requires a QApplication instance for Qt WebEngine functionality. ```cpp int main(int argc, char *argv[]) { QApplication app(argc, argv); QCoreApplication::setOrganizationName("QtExamples"); QCoreApplication::setApplicationName("html2pdf"); QCoreApplication::setApplicationVersion(QT_VERSION_STR); QCommandLineParser parser; parser.setApplicationDescription( QCoreApplication::translate("main", "Converts the web page INPUT into the PDF file OUTPUT.")); parser.addHelpOption(); parser.addVersionOption(); parser.addPositionalArgument( QCoreApplication::translate("main", "INPUT"), QCoreApplication::translate("main", "Input URL for PDF conversion.")); parser.addPositionalArgument( QCoreApplication::translate("main", "OUTPUT"), QCoreApplication::translate("main", "Output file name for PDF conversion.")); parser.process(QCoreApplication::arguments()); const QStringList requiredArguments = parser.positionalArguments(); if (requiredArguments.size() != 2) parser.showHelp(1); Html2PdfConverter converter(requiredArguments.at(0), requiredArguments.at(1)); return converter.run(); } ``` -------------------------------- ### Configure MQTT Subscriptions Project File Source: https://doc.qt.io/archives/qt-5.15/qtmqtt-subscriptions-subscriptions-pro.html Defines the necessary modules, source files, and installation paths for the MQTT Subscriptions example. ```qmake QT += core gui network widgets mqtt TARGET = mqttsubscriptions # The following define makes your compiler emit warnings if you use # any feature of Qt which as been marked as deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += main.cpp\ mainwindow.cpp \ subscriptionwindow.cpp HEADERS += mainwindow.h \ subscriptionwindow.h FORMS += mainwindow.ui \ subscriptionwindow.ui target.path = $$[QT_INSTALL_EXAMPLES]/mqtt/subscriptions INSTALLS += target ``` -------------------------------- ### Initialize and Configure QRadioTuner Source: https://doc.qt.io/archives/qt-5.15/qradiotuner.html Demonstrates basic setup of a radio tuner, including signal connection, band verification, and starting playback. ```cpp radio = new QRadioTuner; connect(radio, SIGNAL(frequencyChanged(int)), this, SLOT(freqChanged(int))); if (radio->isBandSupported(QRadioTuner::FM)) { radio->setBand(QRadioTuner::FM); radio->setFrequency(yourRadioStationFrequency); radio->setVolume(100); radio->start(); } ``` -------------------------------- ### Build and install Qt documentation Source: https://doc.qt.io/archives/qt-5.15/windows-building.html Commands to compile and install the Qt reference documentation for use in Qt Assistant. ```bash nmake docs ``` ```bash nmake install_docs ``` -------------------------------- ### Start a Qt Application on VxWorks Source: https://doc.qt.io/archives/qt-5.15/vxworks.html Example commands to set the library path and launch a Qt 5 application using shared libraries. ```shell putenv "LD_LIBRARY_PATH=/sd0a/lib" cd "/sd0a" rtpSp("", 200, 0x100000, 0, 0x01000000) ``` -------------------------------- ### Main Application Entry Point Source: https://doc.qt.io/archives/qt-5.15/qtwidgets-itemviews-addressbook-example.html Initializes the QApplication and displays the MainWindow. ```cpp int main(int argc, char *argv[]) { #ifdef Q_OS_ANDROID QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif QApplication app(argc, argv); MainWindow mw; mw.show(); return app.exec(); } ``` -------------------------------- ### Create an OPC UA client using QOpcUaProvider Source: https://doc.qt.io/archives/qt-5.15/qopcuaprovider.html Demonstrates how to retrieve available backends and instantiate a client using the first available option. ```cpp QOpcUaProvider provider; QStringList available = provider.availableBackends(); if (!available.isEmpty()) { QOpcUaClient *client = provider.createClient(available[0]); if (client) qDebug() << "Client successfully created"; } ``` -------------------------------- ### Configure project file for KNX Tunneling Source: https://doc.qt.io/archives/qt-5.15/qtknx-feature-feature-pro.html Defines the project structure, required modules, and installation path for the KNX Tunneling Features example. ```qmake TEMPLATE = app TARGET = feature INCLUDEPATH += . CONFIG += c++11 QT += knx widgets network core FORMS += mainwindow.ui HEADERS += deviceitem.h \ mainwindow.h SOURCES += deviceitem.cpp \ main.cpp \ mainwindow.cpp target.path = $$[QT_INSTALL_EXAMPLES]/knx/feature INSTALLS += target ``` -------------------------------- ### Initialize a Qt Quick Application in C++ Source: https://doc.qt.io/archives/qt-5.15/qtdoc-tutorials-alarms-main-cpp.html Sets up the QGuiApplication and loads the main QML file via QQmlApplicationEngine. Includes a connection to handle object creation failures. ```cpp /**************************************************************************** ** ** Copyright (C) 2018 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** BSD License Usage ** Alternatively, you may use this file under the terms of the BSD license ** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include #include int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); QQmlApplicationEngine engine; const QUrl url("qrc:/alarms/main.qml"); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) QCoreApplication::exit(-1); }, Qt::QueuedConnection); engine.load(url); return app.exec(); } ``` -------------------------------- ### Configure Qt OPC UA Viewer project file Source: https://doc.qt.io/archives/qt-5.15/qtopcua-opcuaviewer-opcuaviewer-pro.html Defines the project modules, source files, headers, and installation path for the OPC UA Viewer example. ```qmake QT += opcua widgets CONFIG += c++11 DEPENDPATH += INCLUDEPATH SOURCES += main.cpp \ mainwindow.cpp \ opcuamodel.cpp \ treeitem.cpp \ certificatedialog.cpp #install target.path = $$[QT_INSTALL_EXAMPLES]/opcua/opcuaviewer INSTALLS += target HEADERS += \ mainwindow.h \ opcuamodel.h \ treeitem.h \ certificatedialog.h FORMS += \ certificatedialog.ui \ mainwindow.ui ``` -------------------------------- ### Initialize WebEngine and Server in main.cpp Source: https://doc.qt.io/archives/qt-5.15/qtwebengine-webengine-customdialogs-example.html Sets up the application, initializes QtWebEngine, and configures a local proxy and TCP server for authentication simulation. ```cpp int main(int argc, char *argv[]) { QCoreApplication::setOrganizationName("QtExamples"); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QtWebEngine::initialize(); Application app(argc, argv); QQmlApplicationEngine engine; Server *server = new Server(&engine); engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); QTimer::singleShot(0, server, &Server::run); QNetworkProxy proxy; proxy.setType(QNetworkProxy::HttpProxy); proxy.setHostName("localhost"); proxy.setPort(5555); QNetworkProxy::setApplicationProxy(proxy); return app.exec(); } ``` -------------------------------- ### Main Entry Point Source: https://doc.qt.io/archives/qt-5.15/activeqt-activeqt-qutlook-example.html Initializes the QApplication and displays the AddressView widget. ```cpp #include "addressview.h" #include int main(int argc, char *argv[]) { QApplication a(argc, argv); AddressView view; view.setWindowTitle(QObject::tr("Qt Example - Looking at Outlook")); view.show(); return a.exec(); } ``` -------------------------------- ### Parsing KNX Project Files Source: https://doc.qt.io/archives/qt-5.15/qtknx-knxproj-main-cpp.html This example uses QKnxGroupAddressInfos to parse a specified KNX project file and output details about its structure, including installations and group addresses. ```cpp /****************************************************************************** ** ** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtKnx module. ** ** $QT_BEGIN_LICENSE:GPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3 or (at your option) any later version ** approved by the KDE Free Qt Foundation. The licenses are as published by ** the Free Software Foundation and appearing in the file LICENSE.GPL3 ** included in the packaging of this file. Please review the following ** information to ensure the GNU General Public License requirements will ** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$* ** ******************************************************************************/ #include #include #include #include #include #include int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); QCoreApplication::setApplicationName("knxproj"); QCommandLineParser cliParser; cliParser.setApplicationDescription("KNX Project file parser"); cliParser.addHelpOption(); QCommandLineOption verboseOption({"v","verbose"}, QCoreApplication::translate( "main", "Show more details of the project file.")); cliParser.addOption(verboseOption); QCommandLineOption projFilePathOption(QStringList() << "p" << "project", QCoreApplication::translate("main", "Path to the project file to parse."), QCoreApplication::translate("main", "path")); cliParser.addOption(projFilePathOption); cliParser.process(app); bool verbose = cliParser.isSet(verboseOption); if (!cliParser.isSet(projFilePathOption)) { qInfo() << "Error: Missing project file name" << Qt::endl; cliParser.showHelp(EXIT_FAILURE); } QKnxGroupAddressInfos infos(cliParser.value(projFilePathOption)); infos.parse(); qInfo().noquote() << QString::fromLatin1("Opening project file: %1") .arg(infos.projectFile()); QString status = infos.errorString().isEmpty() ? "No errors" : infos.errorString(); qInfo().noquote() << QString::fromLatin1("Status parsing project: %1") .arg(status); qInfo().noquote() << QString::fromLatin1("Project ids found: %1") .arg(infos.projectIds().size()); if (infos.status() != QKnxGroupAddressInfos::Status::NoError) { qInfo() << "ERROR:" << infos; return EXIT_FAILURE; } for (const auto &projId: infos.projectIds()) { auto installations = infos.installations(projId); qInfo()<< " # project"<availableGeometry(); mainWin.resize(availableGeometry.width() / 2, availableGeometry.height() * 2 / 3); mainWin.move((availableGeometry.width() - mainWin.width()) / 2, (availableGeometry.height() - mainWin.height()) / 2); mainWin.show(); return app.exec(); } ``` -------------------------------- ### Build and install Qt binaries Source: https://doc.qt.io/archives/qt-5.15/configure-options.html Execute the build process and install the resulting binaries to the directory specified during configuration. ```bash make make install ``` -------------------------------- ### start() Source: https://doc.qt.io/archives/qt-5.15/qml-qtquick-animatedsprite.html Starts the sprite animation. ```APIDOC ## start() ### Description Starts the sprite animation. If the animation is already running, calling this method has no effect. ``` -------------------------------- ### start() Source: https://doc.qt.io/archives/qt-5.15/qml-qtmultimedia-camera.html Starts the camera device. ```APIDOC ## start() ### Description Starts the camera device. ``` -------------------------------- ### Initialize QQmlApplicationEngine Source: https://doc.qt.io/archives/qt-5.15/qqmlapplicationengine.html Demonstrates the standard setup for a QML-based application using QQmlApplicationEngine. ```cpp #include #include int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQmlApplicationEngine engine("main.qml"); return app.exec(); } ``` -------------------------------- ### start() Source: https://doc.qt.io/archives/qt-5.15/qml-qtmultimedia-radio.html Starts the radio device. ```APIDOC ## start() ### Description Starts the radio. If the radio is available, this will result in the state becoming ActiveState. ``` -------------------------------- ### Initialize the Notepad Application Source: https://doc.qt.io/archives/qt-5.15/qtwidgets-tutorials-notepad-example.html The main entry point for the application, initializing the QApplication and displaying the main window. ```cpp #include "notepad.h" #include int main(int argc, char *argv[]) { QApplication EditorApp(argc, argv); Notepad Editor; Editor.show(); return EditorApp.exec(); } ``` -------------------------------- ### start Source: https://doc.qt.io/archives/qt-5.15/qbluetoothservicediscoveryagent.html Starts the service discovery process. ```APIDOC ## void start(QBluetoothServiceDiscoveryAgent::DiscoveryMode mode = MinimalDiscovery) ### Description Starts the discovery process using the specified discovery mode. ### Parameters - **mode** (DiscoveryMode) - The mode of discovery (MinimalDiscovery or FullDiscovery). ``` -------------------------------- ### Main Application Entry Point Source: https://doc.qt.io/archives/qt-5.15/qtwidgets-dialogs-trivialwizard-example.html Instantiates the QWizard, adds the pages, and displays the wizard window. ```cpp int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QApplication app(argc, argv); #ifndef QT_NO_TRANSLATION QString translatorFileName = QLatin1String("qtbase_"); translatorFileName += QLocale::system().name(); QTranslator *translator = new QTranslator(&app); if (translator->load(translatorFileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) app.installTranslator(translator); #endif QWizard wizard; wizard.addPage(createIntroPage()); wizard.addPage(createRegistrationPage()); wizard.addPage(createConclusionPage()); wizard.setWindowTitle("Trivial Wizard"); wizard.show(); return app.exec(); } ``` -------------------------------- ### Initialize and run the MQTT client application Source: https://doc.qt.io/archives/qt-5.15/qtmqtt-simpleclient-main-cpp.html The main entry point for the application, setting up the QApplication and displaying the MainWindow. ```cpp /**************************************************************************** ** ** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** BSD License Usage ** Alternatively, you may use this file under the terms of the BSD license ** as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include "mainwindow.h" #include int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); } ``` -------------------------------- ### start Source: https://doc.qt.io/archives/qt-5.15/qaudiooutput.html Starts the audio output process. ```APIDOC ## void start(QIODevice *device) ## QIODevice *start() ### Description Starts sending audio data to the output device. If a device is provided, it reads from it; otherwise, it returns a QIODevice that the user can write data to. ```