### Configure Example Directories and Installation Path Source: https://doc.qt.io/qt-6/22-qdoc-configuration-generalvariables.html Define directories for examples using 'exampledirs' and set the installation path for project examples using 'examplesinstallpath'. The 'examplesinstallpath' must match a directory in 'exampledirs'. ```qdoc exampledirs = ./snippets \ ../../../examples/mymodule examplesinstallpath = mymodule ``` -------------------------------- ### Specifying QDoc Example Installation Path with \meta Source: https://doc.qt.io/qt-6/12-0-qdoc-commands-miscellaneous.html This example demonstrates how to use \meta {installpath} to override the default installation path for an example. This allows for custom placement of examples, independent of the global examplesinstallpath configuration. ```QDoc /*! \example helloworld \title Hello World Example \meta {installpath} {tutorials} */ ``` -------------------------------- ### Install Qt SDK on Windows using Qt Online Installer Source: https://doc.qt.io/qt-6/get-and-install-qt-cli.html Example command for a new installation of the Qt SDK on Windows using the Qt Online Installer. ```bash # Windows: new installation with Qt Online Installer qt-unified-windows-x64-[Qt Online Installer version]-online.exe install qt6.11.1-sdk ``` -------------------------------- ### Main Application Setup Source: https://doc.qt.io/qt-6/qttasktree-tasktree-trafficlight-example.html This C++ code sets up the main application by creating and connecting the necessary components for the QTaskTree and TrafficLight example. It initializes the application, instantiates the interface, task tree, and widget, then shows the widget and starts the task tree before entering the application's event loop. ```cpp int main(int argc, char **argv) { QApplication app(argc, argv); GlueInterface iface; QTaskTree taskTree({recipe(iface)}); TrafficLight widget(iface); widget.show(); taskTree.start(); return app.exec(); } ``` -------------------------------- ### Specify Installation Resources Source: https://doc.qt.io/qt-6/qmake-variable-reference.html Define resources to be installed when 'make install' is executed. This example shows how to specify the installation path for a build target. ```qmake target.path += $$[QT_INSTALL_PLUGINS]/imageformats INSTALLS += target ``` -------------------------------- ### Install Qt SDK on Linux using Qt Online Installer Source: https://doc.qt.io/qt-6/get-and-install-qt-cli.html Example command for a new installation of the Qt SDK on Linux using the Qt Online Installer. ```bash # Linux: new installation with Qt Online Installer qt-unified-linux-x64-[Qt Online Installer version]-online.run install qt6.11.1-sdk ``` -------------------------------- ### Install Qt SDK on macOS using Qt Online Installer Source: https://doc.qt.io/qt-6/get-and-install-qt-cli.html Example commands for mounting the installer, performing a new installation of the Qt SDK on macOS, and detaching the disk image. ```bash # macOS: new installation with Qt Online Installer hdiutil attach qt-unified-macOS-x64-[Qt Online Installer version]-online.dmg /Volumes/qt-unified-macOS-x64-[Qt Online Installer version]-online/qt-unified-macOS-x64-[Qt Online Installer version]-online.app/Contents/MacOS/qt-unified-macOS-x64-[Qt Online Installer version]-online install qt6.11.1-sdk hdiutil detach /Volumes/qt-unified-macOS-x64-[Qt Online Installer version]-online ``` -------------------------------- ### Build Configuration for Mass Example Source: https://doc.qt.io/qt-6/qtquick3dphysics-mass-mass-pro.html This qmake configuration file specifies the required Qt modules (quick, quick3d), the installation path for the example, and lists the source and resource files. ```qmake QT += quick quick3d target.path = $$[QT_INSTALL_EXAMPLES]/quick3dphysics/mass INSTALLS += target SOURCES +=\ main.cpp RESOURCES +=\ qml.qrc OTHER_FILES +=\ doc/src/*.* ``` -------------------------------- ### Start Line Edits Example Client Source: https://doc.qt.io/qt-6/qtvirtualkeyboard-deployment-guide.html Launch the lineedits example application with the '-platform wayland' argument to enable Wayland integration. ```bash ./lineedits -platform wayland ``` -------------------------------- ### start Source: https://doc.qt.io/qt-6/qttasktree-qmappedtasktreerunner-members.html Starts a new task with the given key, group, setup handler, done handler, and call-done callback. ```APIDOC ## start(const Key &, const QtTaskTree::Group &, SetupHandler &&, DoneHandler &&, QtTaskTree::CallDone) ### Description Starts a new task. The task is identified by a unique key. It belongs to a specified group and is executed with the provided setup and done handlers, along with a call-done callback. ### Method void start(const Key &key, const QtTaskTree::Group &group, SetupHandler &&setupHandler, DoneHandler &&doneHandler, QtTaskTree::CallDone callDone) ``` -------------------------------- ### Project Configuration for Simple Example Source: https://doc.qt.io/qt-6/qtquick3dphysics-simple-simple-pro.html This snippet shows the qmake project file configuration for the simple Qt Quick 3D Physics example. It includes necessary Qt modules, installation paths, source files, resources, and other files. ```qmake QT += quick quick3d target.path = $$[QT_INSTALL_EXAMPLES]/quick3dphysics/simple INSTALLS += target SOURCES += main.cpp RESOURCES += qml.qrc OTHER_FILES += doc/src/*.* ``` -------------------------------- ### SBOM Document Path Example Source: https://doc.qt.io/qt-6/sbom.html This example shows the typical installation path for SBOM .spdx documents when using Boot to Qt with the meta-qt6 layer on a Raspberry Pi target. ```text /6.11.1/Boot2Qt/raspberrypi-armv8/toolchain/sysroots/cortexa53-poky-linux/usr/lib/sbom/ ``` -------------------------------- ### Example Usage of QT_DEPLOY_BIN_DIR Source: https://doc.qt.io/qt-6/cmake-variable-qt-deploy-bin-dir.html This example demonstrates how to use QT_DEPLOY_BIN_DIR to define paths for executables and helper applications, and how to generate a deployment script. It also shows installation rules for both Windows/Linux and macOS bundle targets. ```cmake cmake_minimum_required(VERSION 3.16...3.22) project(MyThings) find_package(Qt6 REQUIRED COMPONENTS Core) qt_standard_project_setup() qt_add_executable(MyApp main.cpp) set_target_properties(MyApp PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) # App bundles on macOS have an .app suffix if(APPLE) set(executable_path "$.app") else() set(executable_path "\${QT_DEPLOY_BIN_DIR}/$") endif() # Helper app, not necessarily built as part of this project. qt_add_executable(HelperApp helper.cpp) set(helper_app_path "\${QT_DEPLOY_BIN_DIR}/$") # Generate a deployment script to be executed at install time qt_generate_deploy_script( TARGET MyApp OUTPUT_SCRIPT deploy_script CONTENT " qt_deploy_runtime_dependencies( EXECUTABLE \"${executable_path}\" ADDITIONAL_EXECUTABLES \"${helper_app_path}\" GENERATE_QT_CONF VERBOSE )" ) # Omitting RUNTIME DESTINATION will install a non-bundle target to CMAKE_INSTALL_BINDIR, # which coincides with the default value of QT_DEPLOY_BIN_DIR used above, './bin'. # Installing macOS bundles always requires an explicit BUNDLE DESTINATION option. install(TARGETS MyApp HelperApp # Install to CMAKE_INSTALL_PREFIX/bin/MyApp.exe # and ./binHelperApp.exe BUNDLE DESTINATION . # Install to CMAKE_INSTALL_PREFIX/MyApp.app/Contents/MacOS/MyApp ) install(SCRIPT ${deploy_script}) # Add its runtime dependencies ``` -------------------------------- ### Basic CaptureSession Setup Source: https://doc.qt.io/qt-6/qml-qtmultimedia-capturesession.html This snippet demonstrates a basic setup of CaptureSession, connecting a Camera, ImageCapture, MediaRecorder, and a VideoOutput for preview. It also includes starting the camera in the Component.onCompleted handler. ```qml CaptureSession { id: captureSession camera: Camera { id: camera } imageCapture: ImageCapture { id: imageCapture } recorder: MediaRecorder { id: recorder } videoOutput: preview Component.onCompleted: { camera.start() } } ``` -------------------------------- ### Initiate Bidirectional Streaming Call Source: https://doc.qt.io/qt-6/qtgrpc-clientguide-example.html Example of how to start the bidirectional streaming process with an initial request, typically used in a main function or test setup. ```cpp clientGuide.bidirectionalStreaming(ClientGuide::createRequest(3)); ``` -------------------------------- ### Main Function Setup Source: https://doc.qt.io/qt-6/qtwidgets-rhi-simplerhiwidget-example.html Sets up the QApplication, creates an ExampleRhiWidget, adds it to a layout, and displays the main window. This is the entry point for the application. ```cpp int main(int argc, char **argv) { QApplication app(argc, argv); ExampleRhiWidget *rhiWidget = new ExampleRhiWidget; QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(rhiWidget); QWidget w; w.setLayout(layout); w.resize(1280, 720); w.show(); return app.exec(); } ``` -------------------------------- ### Setting up and starting QOpcUaGdsClient Source: https://doc.qt.io/qt-6/qopcuagdsclient.html Demonstrates the basic setup and initiation of a QOpcUaGdsClient. Connect to signals for authentication and registration success. Ensure all necessary configurations like backend, endpoint, identity, PKI, application record, and CSR presets are set before starting. ```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(); ``` -------------------------------- ### Setting Install Directories and Deploying an Application Source: https://doc.qt.io/qt-6/cmake-variable-qt-deploy-lib-dir.html This example demonstrates how to set CMake install directories and then use qt_deploy_runtime_dependencies to deploy an application's runtime dependencies. It shows the initialization of QT_DEPLOY_* counterparts by setting CMAKE_INSTALL_*DIR variables. ```cmake cmake_minimum_required(VERSION 3.16...3.22) project(MyThings) # The following CMAKE_INSTALL_*DIR variables are used to initialize their # QT_DEPLOY_*_DIR counterparts. set(CMAKE_INSTALL_BINDIR "mybindir") set(CMAKE_INSTALL_LIBDIR "mylibdir") set(CMAKE_INSTALL_LIBEXECDIR "mylibexecdir") find_package(Qt6 REQUIRED COMPONENTS Core) qt_standard_project_setup() qt_add_executable(MyApp main.cpp) set(deploy_script "${CMAKE_CURRENT_BINARY_DIR}/deploy_MyApp.cmake") file(GENERATE OUTPUT ${deploy_script} CONTENT " set(QT_DEPLOY_PLUGINS_DIR \"mypluginsdir\") set(QT_DEPLOY_TRANSLATIONS_DIR \"i18n\") include(\"${QT_DEPLOY_SUPPORT}\") qt_deploy_runtime_dependencies( EXECUTABLE \"\ ${QT_DEPLOY_BIN_DIR}/$\" )") install(SCRIPT ${deploy_script}) ``` -------------------------------- ### Navigate to Example Directory Source: https://doc.qt.io/qt-6/windows-deployment.html Change to the directory containing the application example you want to build. ```bash cd examples\tools\plugandpaint ``` -------------------------------- ### Get Start Drag Distance Source: https://doc.qt.io/qt-6/qapplication.html Get the minimum distance in pixels required to start a drag operation with startDragDistance. This value affects drag sensitivity. ```cpp int startDragDistance() const ``` -------------------------------- ### Set Up Qt Quick Test Entry Point with Setup Class Source: https://doc.qt.io/qt-6/qquicktest.html Use QUICK_TEST_MAIN_WITH_SETUP for applications requiring custom setup before running QML tests. It takes a QObject-derived class for initialization. ```cpp // src_qmltest_qquicktest.cpp #include #include #include #include class Setup : public QObject { Q_OBJECT public: Setup() {} public slots: void applicationAvailable() { // Initialization that only requires the QGuiApplication object to be available } void qmlEngineAvailable(QQmlEngine *engine) { // Initialization requiring the QQmlEngine to be constructed engine->rootContext()->setContextProperty("myContextProperty", QVariant(true)); } void cleanupTestCase() { // Implement custom resource cleanup } }; QUICK_TEST_MAIN_WITH_SETUP(mytest, Setup) #include "src_qmltest_qquicktest.moc" ``` -------------------------------- ### Generate Custom Deployment Script Example Source: https://doc.qt.io/qt-6/qt-generate-deploy-script.html An example demonstrating how to use qt_generate_deploy_script to create a custom deployment script for an executable. The script is installed and then executed during the installation process. ```cmake cmake_minimum_required(VERSION 3.16...3.22) project(MyThings) find_package(Qt6 REQUIRED COMPONENTS Core) qt_standard_project_setup() qt_add_executable(MyApp main.cpp) install(TARGETS MyApp BUNDLE DESTINATION . RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) qt_generate_deploy_script( TARGET MyApp OUTPUT_SCRIPT deploy_script CONTENT " qt_deploy_runtime_dependencies( EXECUTABLE $ ) ") install(SCRIPT ${deploy_script}) ``` -------------------------------- ### Start Drag Time Source: https://doc.qt.io/qt-6/qstylehints.html Gets the time in milliseconds to start a drag operation. ```APIDOC ## startDragTime ### Description Returns the time in milliseconds to start a drag operation. ### Method int ### Endpoint startDragTime() ### Parameters None ### Response #### Success Response - **int**: The drag start time in milliseconds. ``` -------------------------------- ### Main Function Setup Source: https://doc.qt.io/qt-6/qtwidgets-widgets-tablet-example.html Initializes the TabletApplication, creates a TabletCanvas and MainWindow, and shows the main window. Ensure QApplication is instantiated before setting up other UI elements. ```cpp int main(int argv, char *args[]) { TabletApplication app(argv, args); TabletCanvas *canvas = new TabletCanvas; app.setCanvas(canvas); MainWindow mainWindow(canvas); mainWindow.resize(500, 500); mainWindow.show(); return app.exec(); } ``` -------------------------------- ### Start Drag Distance Source: https://doc.qt.io/qt-6/qstylehints.html Gets the distance in pixels to start a drag operation. ```APIDOC ## startDragDistance ### Description Returns the distance in pixels to start a drag operation. ### Method int ### Endpoint startDragDistance() ### Parameters None ### Response #### Success Response - **int**: The drag start distance in pixels. ``` -------------------------------- ### Get the start angle of the pie Source: https://doc.qt.io/qt-6/qpieseries.html Returns the start angle of the pie in degrees. ```cpp qreal startAngle() const ``` -------------------------------- ### Minimal Example Source: https://doc.qt.io/qt-6/qhttpserver.html A minimal example demonstrating how to set up and run a QHttpServer. ```APIDOC ## Minimal Example ```cpp QHttpServer server; server.route("/", [] () { return "hello world"; }); auto tcpserver = new QTcpServer(); if (!tcpserver->listen() || !server.bind(tcpserver)) { delete tcpserver; return -1; } qDebug() << "Listening on port" << tcpserver->serverPort(); ``` ``` -------------------------------- ### Initialize HTTP Server and Basic Route Source: https://doc.qt.io/qt-6/qthttpserver-simple-example.html Sets up the QCoreApplication and QHttpServer, then defines a simple route for the root path that returns 'Hello world'. ```cpp QCoreApplication app(argc, argv); QHttpServer httpServer; httpServer.route("/", []() { return "Hello world"; }); ``` -------------------------------- ### Main Function Setup Source: https://doc.qt.io/qt-6/qtwidgets-itemviews-stardelegate-example.html Initializes the QApplication, creates a QTableWidget, sets a StarDelegate, configures edit triggers and selection behavior, and displays the table. ```cpp int main(int argc, char *argv[]) { QApplication app(argc, argv); QTableWidget tableWidget(4, 4); tableWidget.setItemDelegate(new StarDelegate); tableWidget.setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked); tableWidget.setSelectionBehavior(QAbstractItemView::SelectRows); tableWidget.setHorizontalHeaderLabels({"Title", "Genre", "Artist", "Rating"}); populateTableWidget(&tableWidget); tableWidget.resizeColumnsToContents(); tableWidget.resize(500, 300); tableWidget.show(); return app.exec(); } ``` -------------------------------- ### Start Drag Velocity Source: https://doc.qt.io/qt-6/qstylehints.html Gets the velocity in pixels per second to start a drag operation. ```APIDOC ## startDragVelocity ### Description Returns the velocity in pixels per second to start a drag operation. ### Method int ### Endpoint startDragVelocity() ### Parameters None ### Response #### Success Response - **int**: The drag start velocity in pixels per second. ``` -------------------------------- ### Create Build and Installation Directories Source: https://doc.qt.io/qt-6/qtmultimedia-building-ffmpeg-ios.html Sets up the necessary directories for building and installing FFmpeg. Navigate into the build directory to proceed. ```bash mkdir ~/ffmpeg/build mkdir ~/ffmpeg/installed cd ~/ffmpeg/build ``` -------------------------------- ### Main Application Entry Point Source: https://doc.qt.io/qt-6/qtspatialaudio-audiopanning-main-cpp.html Sets up the QApplication, command-line argument parsing, and displays the main AudioWidget. Handles optional audio file argument. ```cpp int main(int argc, char **argv) { QApplication app(argc, argv); QCoreApplication::setApplicationVersion(qVersion()); QGuiApplication::setApplicationDisplayName(AudioWidget::tr("Spatial Audio test application")); QCommandLineParser commandLineParser; commandLineParser.addVersionOption(); commandLineParser.addHelpOption(); commandLineParser.addPositionalArgument("Audio File", "Audio File to play"); commandLineParser.process(app); AudioWidget w; w.show(); if (!commandLineParser.positionalArguments().isEmpty()) w.setFile(commandLineParser.positionalArguments().constFirst()); return app.exec(); } ``` -------------------------------- ### Get Start of Day DateTime Source: https://doc.qt.io/qt-6/newclasses65.html Returns a QDateTime representing the start of the day for the current QDate. ```cpp QDateTime startOfDay() const ``` -------------------------------- ### New Qt Installation with User Interaction Source: https://doc.qt.io/qt-6/get-and-install-qt-cli.html Use the Qt Online Installer for new installations. Specify the installation directory with `--root` and the packages to install using the `install` command. ```bash # Windows: new installation with user interaction qt-unified-windows-x64-[Qt Online Installer version]-online.exe --root C:\Users\[username]\installation_dir install qt.qt6.6111.win64_msvc2022_64 ``` ```bash # macOS: new installation with user interaction qt-unified-macOS-x64-[Qt Online Installer version]-online.dmg --root /home//installation_dir install qt.qt6.6111.clang_64 ``` ```bash # linux: new installation with user interaction qt-unified-linux-x64-[Qt Online Installer version]-online.run --root /home//installation_dir install qt.qt6.6111.linux_gcc_64 ``` -------------------------------- ### Example Usage Source: https://doc.qt.io/qt-6/qwebengineurlschemehandler.html An example demonstrating how to create a custom scheme handler, register a scheme, and install the handler. ```APIDOC ```cpp class MySchemeHandler : public QWebEngineUrlSchemeHandler { public: MySchemeHandler(QObject *parent = nullptr); void requestStarted(QWebEngineUrlRequestJob *job) { const QByteArray method = job->requestMethod(); const QUrl url = job->requestUrl(); if (isValidUrl(url)) { if (method == QByteArrayLiteral("GET")) job->reply(QByteArrayLiteral("text/html"), makeReply(url)); else // Unsupported method job->fail(QWebEngineUrlRequestJob::RequestDenied); } else { // Invalid URL job->fail(QWebEngineUrlRequestJob::UrlNotFound); } } bool isValidUrl(const QUrl &url) const // .... QIODevice *makeReply(const QUrl &url) // .... }; int main(int argc, char **argv) { QWebEngineUrlScheme scheme("myscheme"); scheme.setSyntax(QWebEngineUrlScheme::Syntax::HostAndPort); scheme.setDefaultPort(2345); scheme.setFlags(QWebEngineUrlScheme::SecureScheme); QWebEngineUrlScheme::registerScheme(scheme); // ... QApplication app(argc, argv); // ... // installUrlSchemeHandler does not take ownership of the handler. MySchemeHandler *handler = new MySchemeHandler(parent); QWebEngineProfile::defaultProfile()->installUrlSchemeHandler("myscheme", handler); } ``` ``` -------------------------------- ### Main Program Entry Point Source: https://doc.qt.io/qt-6/qtnetwork-rsslisting-example.html Initializes the Qt application, creates an RSSListing widget with a default URL, shows the widget, and starts the event loop. ```cpp int main(int argc, char **argv) { QApplication app(argc, argv); RSSListing rsslisting(u"https://www.qt.io/blog/rss.xml"_s); rsslisting.show(); return app.exec(); } ``` -------------------------------- ### Example Usage: Start and Stop Recording Source: https://doc.qt.io/qt-6/qml-qtmultimedia-mediarecorder.html Shows how to implement buttons to start and stop the media recording. ```APIDOC ``` CameraButton { text: "Record" visible: recorder.recorderState !== MediaRecorder.RecordingState onClicked: recorder.record() } CameraButton { id: stopButton text: "Stop" visible: recorder.recorderState === MediaRecorder.RecordingState onClicked: recorder.stop() } ``` ``` -------------------------------- ### Referencing an Example with \example Command Source: https://doc.qt.io/qt-6/22-qdoc-configuration-generalvariables.html Use the \example command to reference a specific example. The path is relative to the 'exampledirs' and 'examplesinstallpath' configuration. ```qdoc /*! \example basic/hello ... */ ``` -------------------------------- ### Example: Get Container IP Address Source: https://doc.qt.io/qt-6/qtcoap-quicksecureclient-example.html An example of inspecting a Docker container to find its IP address. ```bash $ docker inspect 5e46502df88f | grep IPAddress ... "IPAddress": "172.17.0.2", ... ``` -------------------------------- ### Main Entry Point for Qutlook Example Source: https://doc.qt.io/qt-6/activeqt-activeqt-qutlook-example.html Sets up the QApplication, instantiates the AddressView widget, sets its window title, shows the widget, and starts the Qt event loop. This is the standard entry point for a Qt application. ```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(); } ``` -------------------------------- ### Task Setup Handler Example Source: https://doc.qt.io/qt-6/qttasktree-module.html Defines a setup handler for a QProcessTask to configure the program and arguments before execution. The setup handler receives a reference to the QProcess object. ```cpp const auto onSetup = [](QProcess &process) { process.setProgram("sleep"); process.setArguments({"3"}); }; const Group root { QProcessTask(onSetup) }; ``` -------------------------------- ### Main Application Entry Point Source: https://doc.qt.io/qt-6/qmake-precompiledheaders.html Sets up a Qt application, instantiates custom objects, connects signals and slots, and starts the event loop. ```c++ #include #include #include #include "myobject.h" #include "mydialog.h" int main(int argc, char **argv) { QApplication app(argc, argv); MyObject obj; MyDialog dialog; dialog.connect(dialog.aButton, SIGNAL(clicked()), SLOT(close())); dialog.show(); return app.exec(); } ``` -------------------------------- ### Get Help for Installer Commands Source: https://doc.qt.io/qt-6/get-and-install-qt-cli.html Use the --help option with the installer executable to view available commands and options. ```bash --help ``` -------------------------------- ### Qt Application Entry Point Source: https://doc.qt.io/qt-6/qtlocation-minimal-map-example.html Sets up the QGuiApplication, loads the main QML file using QQmlApplicationEngine, and starts the application event loop. ```cpp int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); return app.exec(); } ``` -------------------------------- ### Start Second Stage Animation Source: https://doc.qt.io/qt-6/qtopengl-hellogles3-example.html Starts a new rotation animation after a delay. This is part of the GLWindow's animation setup. ```cpp void GLWindow::startSecondStage() { QPropertyAnimation* r2Anim = new QPropertyAnimation(this, QByteArrayLiteral("r2")); r2Anim->setStartValue(0.0f); r2Anim->setEndValue(360.0f); r2Anim->setDuration(20000); r2Anim->setLoopCount(-1); r2Anim->start(); } ``` -------------------------------- ### Main Application Entry Point Source: https://doc.qt.io/qt-6/qtwidgets-draganddrop-dropsite-example.html Initializes the QApplication, creates the main window, shows it, and starts the application's event loop. ```cpp int main(int argc, char *argv[]) { QApplication app(argc, argv); DropSiteWindow window; window.show(); return app.exec(); } ``` -------------------------------- ### Starting a COM Server Source: https://doc.qt.io/qt-6/qaxfactory.html Starts the COM server with a specified type. The server is automatically started if the executable is launched with the '-activex' parameter. This example shows how to switch to a single-instance server. ```cpp if (QAxFactory::isServer()) { QAxFactory::stopServer(); QAxFactory::startServer(QAxFactory::SingleInstance); } ``` -------------------------------- ### Get Milliseconds Since Start of Day Source: https://doc.qt.io/qt-6/qtime.html Calculate the total number of milliseconds from the start of the day to the time represented by the QTime object. ```cpp int msecs = time.msecsSinceStartOfDay(); ``` -------------------------------- ### Main Application Entry Point Source: https://doc.qt.io/qt-6/qt3d-simple-cpp-example.html Initializes the Qt GUI application, sets up the Qt 3D window, configures the camera, and starts the application event loop. ```cpp int main(int argc, char* argv[]) { QGuiApplication app(argc, argv); Qt3DExtras::Qt3DWindow view; Qt3DCore::QEntity *scene = createScene(); // Camera Qt3DRender::QCamera *camera = view.camera(); camera->lens()->setPerspectiveProjection(45.0f, 16.0f/9.0f, 0.1f, 1000.0f); camera->setPosition(QVector3D(0, 0, 40.0f)); camera->setViewCenter(QVector3D(0, 0, 0)); // For camera controls Qt3DExtras::QOrbitCameraController *camController = new Qt3DExtras::QOrbitCameraController(scene); camController->setLinearSpeed( 50.0f ); camController->setLookSpeed( 180.0f ); camController->setCamera(camera); view.setRootEntity(scene); view.show(); return app.exec(); } ``` -------------------------------- ### Build Configuration for Cannon Example Source: https://doc.qt.io/qt-6/qtquick3dphysics-cannon-cannon-pro.html This qmake configuration sets up the build for the Cannon example, including necessary Qt modules and installation paths. ```qmake QT += quick quick3d target.path = $$[QT_INSTALL_EXAMPLES]/quick3dphysics/cannon INSTALLS += target SOURCES +=\ main.cpp RESOURCES +=\ qml.qrc OTHER_FILES +=\ doc/src/*.* ``` -------------------------------- ### Initialize Browser Application Source: https://doc.qt.io/qt-6/qtwebengine-webenginewidgets-simplebrowser-example.html Sets up the application, configures WebEngine settings, and creates the main browser window. Opens the Qt Homepage if no URL is provided via command line. ```cpp int main(int argc, char **argv) { QCoreApplication::setOrganizationName("QtExamples"); QApplication app(argc, argv); app.setWindowIcon(QIcon(u":AppLogoColor.png"_s)); QLoggingCategory::setFilterRules(u"qt.webenginecontext.debug=true"_s); QWebEngineProfile::defaultProfile()->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, true); QWebEngineProfile::defaultProfile()->settings()->setAttribute(QWebEngineSettings::DnsPrefetchEnabled, true); QWebEngineProfile::defaultProfile()->settings()->setAttribute( QWebEngineSettings::ScreenCaptureEnabled, true); QUrl url = commandLineUrlArgument(); Browser browser; bool offTheRecord = isSingleProcessMode(); BrowserWindow *window = browser.createHiddenWindow(offTheRecord); window->tabWidget()->setUrl(url); window->show(); return app.exec(); } ``` -------------------------------- ### Query Specific Installation Path Source: https://doc.qt.io/qt-6/qmake-environment-reference.html This example demonstrates how to query the installation prefix of Qt for the current qmake version using the QT_INSTALL_PREFIX property. ```bash qmake -query "QT_INSTALL_INSTALL_PREFIX" ``` -------------------------------- ### Dynamically Create Application Instance Source: https://doc.qt.io/qt-6/qapplication.html This example shows how to dynamically create an appropriate application instance (QApplication, QCoreApplication) based on command-line arguments. It's useful for applications that need to support both GUI and non-GUI modes. ```cpp QCoreApplication* createApplication(int &argc, char *argv[]) { for (int i = 1; i < argc; ++i) { if (!qstrcmp(argv[i], "-no-gui")) return new QCoreApplication(argc, argv); } return new QApplication(argc, argv); } int main(int argc, char* argv[]) { QScopedPointer app(createApplication(argc, argv)); if (qobject_cast(app.data())) { // start GUI version... } else { // start non-GUI version... } return app->exec(); } ``` -------------------------------- ### Running Qt D-Bus Viewer Source: https://doc.qt.io/qt-6/qdbusviewer.html Execute the qdbusviewer tool from the installation directory of your Qt version. This example shows the path for a Linux/X11 installation. ```bash /6.11.1/gcc_64/bin/qdbusviewer ``` -------------------------------- ### Wiggly Example Project Setup Source: https://doc.qt.io/qt-6/qtquickeffectmaker-wiggly-wiggly-pro.html This qmake configuration sets up a basic Qt Quick application for the Wiggly effect. It includes the necessary Qt modules and specifies the resource file. ```qmake TEMPLATE = app QT += quick qml SOURCES += main.cpp RESOURCES += qml.qrc target.path = $$[QT_INSTALL_EXAMPLES]/quickeffectmaker/wiggly INSTALLS += target ``` -------------------------------- ### Get Captured Substring Offsets Source: https://doc.qt.io/qt-6/qregularexpression.html Use `capturedStart()` and `capturedEnd()` to get the starting and ending offsets of a captured substring within the subject string. ```cpp QRegularExpression re("abc(\\d+)def"); QRegularExpressionMatch match = re.match("XYZabc123defXYZ"); if (match.hasMatch()) { int startOffset = match.capturedStart(1); // startOffset == 6 int endOffset = match.capturedEnd(1); // endOffset == 9 // ... } ``` -------------------------------- ### Main Entry Point for Qt Quick Test with Setup Source: https://doc.qt.io/qt-6/qml-qttest-testcase.html Defines the main entry point for a Qt Quick test application, incorporating a custom setup class. This is used when custom initialization or cleanup is required. ```cpp #include #include "setup.h" QUICK_TEST_MAIN_WITH_SETUP(TestQML, Setup) ``` -------------------------------- ### Get the start point of a QLinearGradient Source: https://doc.qt.io/qt-6/qlineargradient.html Returns the start point of this linear gradient in logical coordinates. Use this to retrieve the beginning point of the gradient. ```cpp QPointF QLinearGradient::start() const ``` -------------------------------- ### Example Usage Source: https://doc.qt.io/qt-6/qparallelanimationgroup.html Demonstrates how to create and start a QParallelAnimationGroup with multiple animations. ```APIDOC ## Example ```cpp QParallelAnimationGroup *group = new QParallelAnimationGroup; group->addAnimation(anim1); group->addAnimation(anim2); group->start(); ``` ### Description This example shows how to create a parallel animation group and add two animations (`anim1` and `anim2`) to it. The `start()` method is then called to run all animations concurrently. `anim1` and `anim2` are assumed to be pre-configured QPropertyAnimations. ``` -------------------------------- ### Main Application Entry Point Source: https://doc.qt.io/qt-6/qtwidgets-graphicsview-collidingmice-example.html Initializes the QApplication and sets up the main application window. This is the starting point for the Qt application. ```cpp int main(int argc, char **argv) { QApplication app(argc, argv); ``` -------------------------------- ### Conical Gradient Example Source: https://doc.qt.io/qt-6/qcanvasconicalgradient.html This example demonstrates how to create and use a QCanvasConicalGradient to fill an ellipse. It sets the center, start angle, and multiple color stops for the gradient. ```cpp QRectF rect(20, 20, 160, 160); QCanvasConicalGradient cg(rect.center(), 1.75 * M_PI); cg.setColorAt(0.0, "#fdbb2d"); cg.setColorAt(0.5, "#1a2a6c"); cg.setColorAt(1.0, "#fdbb2d"); p->setFillStyle(cg); p->beginPath(); p->ellipse(rect); p->fill(); ``` -------------------------------- ### Configure Example Project URL with Path Placeholder Source: https://doc.qt.io/qt-6/25-qdoc-configuration-derivedprojects.html Use \1 as a placeholder for the example path when the URL contains additional components like query strings. This allows for dynamic URL generation. ```qdoc url.examples = "https://code.qt.io/cgit/qt/qtbase.git/tree/examples/\1?h=$QT_VER" examplesinstallpath = corelib ``` -------------------------------- ### setupStarted Source: https://doc.qt.io/qt-6/qhelpenginecore.html Signal emitted when the help engine setup process begins. ```APIDOC ## setupStarted ### Description This signal is emitted when setup is started. ### Signal `void QHelpEngineCore::setupStarted()` ``` -------------------------------- ### JavaScript Execution Example Source: https://doc.qt.io/qt-6/qwebengineframe.html Example of running JavaScript to get the document title and logging the result using a lambda callback. Only JSON-compatible data types can be returned. ```cpp page.runJavaScript("document.title", [](const QVariant &v) { qDebug() << v.toString(); }); ``` -------------------------------- ### Main Application Entry Point Source: https://doc.qt.io/qt-6/qtcore-ipc-sharedmemory-example.html Standard Qt application setup, creating the main dialog and starting the event loop. ```cpp int main(int argc, char *argv[]) { QApplication application(argc, argv); Dialog dialog; dialog.show(); return application.exec(); } ``` -------------------------------- ### Start Bluetooth Device Discovery Source: https://doc.qt.io/qt-6/qbluetoothdevicediscoveryagent.html Create a QBluetoothDeviceDiscoveryAgent, connect to the deviceDiscovered signal, and start the discovery process. This is the basic setup for finding nearby Bluetooth devices. ```cpp void MyClass::startDeviceDiscovery() { // Create a discovery agent and connect to its signals QBluetoothDeviceDiscoveryAgent *discoveryAgent = new QBluetoothDeviceDiscoveryAgent(this); connect(discoveryAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)), this, SLOT(deviceDiscovered(QBluetoothDeviceInfo))); // Start a discovery discoveryAgent->start(); //... } ``` ```cpp // In your local slot, read information about the found devices void MyClass::deviceDiscovered(const QBluetoothDeviceInfo &device) { qDebug() << "Found new device:" << device.name() << '(' << device.address().toString() << ')'; } ``` -------------------------------- ### Complete Minimal Q3DSurface Example Source: https://doc.qt.io/qt-6/q3dsurface-qtdatavis.html A complete C++ example demonstrating the construction and display of a minimal Q3DSurface graph, including necessary includes and application setup. ```cpp #include int main(int argc, char **argv) { qputenv("QSG_RHI_BACKEND", "opengl"); 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(); } ``` -------------------------------- ### qt_standard_project_setup Source: https://doc.qt.io/qt-6/cmake-commands-qtcore.html Setup project-wide defaults to a standard arrangement. ```APIDOC ## qt_standard_project_setup ### Description Setup project-wide defaults to a standard arrangement. ### Method N/A (CMake command) ### Endpoint N/A (CMake command) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```cmake qt_standard_project_setup() ``` ### Response N/A (CMake command modifies build configuration) ``` -------------------------------- ### firstSetColumn Source: https://doc.qt.io/qt-6/qvcandlestickmodelmapper-qtcharts.html Gets or sets the starting column for the data set in the candlestick series. ```APIDOC ## firstSetColumn ### Description Gets or sets the starting column for the data set in the candlestick series. ### Getter Signature int firstSetColumn() const ### Setter Signature void setFirstSetColumn(int _firstSetColumn_) ### Parameters * **_firstSetColumn_** (int) - The starting column index. ``` -------------------------------- ### Basic Connection Setup Source: https://doc.qt.io/qt-6/qml-qtopcua-connection.html Sets the backend for the connection and initiates a connection to a specified endpoint. Ensure the backend is set before attempting to connect. ```qml import QtOpcUa as QtOpcUa QtOpcUa.Connection { backend: "open62541" } Component.onCompleted: { connection.connectToEndpoint("opc.tcp://127.0.0.1:43344"); } ``` -------------------------------- ### firstSetRow Source: https://doc.qt.io/qt-6/qhcandlestickmodelmapper-qtcharts.html Gets or sets the starting row index for the candlestick data set. ```APIDOC ## firstSetRow ### Description Gets or sets the starting row index for the candlestick data set. ### Properties - **firstSetRow** : int ### Public Functions - int **firstSetRow**() const - void **setFirstSetRow**(int _firstSetRow_) ### Signals - void **firstSetRowChanged**() ``` -------------------------------- ### Setting Install Directories and Deploying an Executable Source: https://doc.qt.io/qt-6/cmake-variable-qt-deploy-libexec-dir.html This example demonstrates how to set custom installation directories for binaries, libraries, and executables, and then uses a generated deployment script to deploy runtime dependencies for an executable. It shows the initialization of QT_DEPLOY_*_DIR counterparts by setting CMAKE_INSTALL_*DIR variables before finding the Qt6 package. ```cmake cmake_minimum_required(VERSION 3.16...3.22) project(MyThings) # The following CMAKE_INSTALL_*DIR variables are used to initialize their # QT_DEPLOY_*_DIR counterparts. set(CMAKE_INSTALL_BINDIR "mybindir") set(CMAKE_INSTALL_LIBDIR "mylibdir") set(CMAKE_INSTALL_LIBEXECDIR "mylibexecdir") find_package(Qt6 REQUIRED COMPONENTS Core) qt_standard_project_setup() qt_add_executable(MyApp main.cpp) set(deploy_script "${CMAKE_CURRENT_BINARY_DIR}/deploy_MyApp.cmake") file(GENERATE OUTPUT ${deploy_script} CONTENT " set(QT_DEPLOY_PLUGINS_DIR \"mypluginsdir\") set(QT_DEPLOY_TRANSLATIONS_DIR \"i18n\") include(\"${QT_DEPLOY_SUPPORT}\") qt_deploy_runtime_dependencies( EXECUTABLE \"${QT_DEPLOY_BIN_DIR}/$\" )") install(SCRIPT ${deploy_script}) ``` -------------------------------- ### setupData Source: https://doc.qt.io/qt-6/qhelpenginecore.html Initializes the help engine by processing the collection file. This function can be called explicitly to force immediate initialization. ```APIDOC ## setupData ### Description Sets up the help engine by processing the information found in the collection file and returns true if successful; otherwise returns false. By calling the function, the help engine is forced to initialize itself immediately. Most of the times, this function does not have to be called explicitly because getter functions which depend on a correctly set up help engine do that themselves. ### Method `bool QHelpEngineCore::setupData()` ### Note `qsqlite4.dll` needs to be deployed with the application as the help system uses the sqlite driver when loading help collections. ### Returns bool - True if the setup was successful, otherwise false. ``` -------------------------------- ### Main Application Entry Point Source: https://doc.qt.io/qt-6/qtdoc-demos-documentviewer-example.html Sets up the application, parses command line arguments, initializes the main window, and starts the event loop. It handles loading translations and checks for necessary viewer plugins before showing the main window. ```cpp int main(int argc, char *argv[]) { QApplication app(argc, argv); QCoreApplication::setOrganizationName("QtProject"_L1); QCoreApplication::setApplicationName("DocumentViewer"_L1); QCoreApplication::setApplicationVersion("1.0"_L1); Translator mainTranslator; mainTranslator.setBaseName("docviewer"_L1); mainTranslator.install(); QCommandLineParser parser; parser.setApplicationDescription(Tr::tr("A viewer for JSON, PDF and text files")); parser.addHelpOption(); parser.addVersionOption(); parser.addPositionalArgument("File"_L1, Tr::tr("JSON, PDF or text file to open")); parser.process(app); const QStringList &positionalArguments = parser.positionalArguments(); const QString &fileName = (positionalArguments.count() > 0) ? positionalArguments.at(0) : QString(); MainWindow w(mainTranslator); // Start application only if plugins are available if (!w.hasPlugins()) { QMessageBox::critical(nullptr, Tr::tr("No viewer plugins found"), Tr::tr("Unable to load viewer plugins. Exiting application.")); return 1; } w.show(); if (!fileName.isEmpty()) w.openFile(fileName); return app.exec(); } ``` -------------------------------- ### Build Configuration for CharacterController Example Source: https://doc.qt.io/qt-6/qtquick3dphysics-charactercontroller-charactercontroller-pro.html This snippet shows the qmake build configuration for the CharacterController example, including necessary Qt modules, installation paths, source files, and resources. ```qmake QT += quick quick3d target.path = $$[QT_INSTALL_EXAMPLES]/quick3dphysics/charactercontroller INSTALLS += target SOURCES += \ main.cpp RESOURCES += \ qml.qrc OTHER_FILES += \ doc/src/*.* ``` -------------------------------- ### Configure Qt Project for Water Pump Example Source: https://doc.qt.io/qt-6/qtopcua-waterpump-waterpump-qml-waterpump-qml-pro.html This configuration is for a Qt Quick application that uses OPC UA. It includes necessary modules and specifies installation paths for examples. ```pro QT += quick CONFIG += c++11 SOURCES += main.cpp RESOURCES += qml.qrc target.path = $$[QT_INSTALL_EXAMPLES]/opcua/waterpump/waterpump-qml INSTALLS += target ``` -------------------------------- ### Simple Screen Capture Session Source: https://doc.qt.io/qt-6/qml-qtmultimedia-screencapture.html This example demonstrates a basic setup for screen capture using ScreenCapture and displaying the output in a VideoOutput. Ensure the 'import QtMultimedia' statement is present. ```QML CaptureSession { id: captureSession screenCapture: ScreenCapture { id: screenCapture active: true } videoOutput: VideoOutput { id: videoOutput } } ``` -------------------------------- ### Basic QVulkanInstance Setup and QWindow Creation Source: https://doc.qt.io/qt-6/qvulkaninstance.html This snippet demonstrates the fundamental steps to create a QVulkanInstance and a Vulkan-capable QWindow. It includes error handling for Vulkan availability and shows how to initialize the window for rendering. ```cpp class VulkanWindow : public QWindow { public: VulkanWindow() { setSurfaceType(VulkanSurface); } void exposeEvent(QExposeEvent *) { if (isExposed()) { if (!m_initialized) { m_initialized = true; // initialize device, swapchain, etc. QVulkanInstance *inst = vulkanInstance(); QVulkanFunctions *f = inst->functions(); uint32_t devCount = 0; f->vkEnumeratePhysicalDevices(inst->vkInstance(), &devCount, nullptr); // ... // build the first frame render(); } } } bool event(QEvent *e) { if (e->type() == QEvent::UpdateRequest) render(); return QWindow::event(e); } void render() { // ... requestUpdate(); // render continuously } private: bool m_initialized = false; }; int main(int argc, char **argv) { QGuiApplication app(argc, argv); QVulkanInstance inst; if (!inst.create()) { qWarning("Vulkan not available"); return 1; } VulkanWindow window; window.showMaximized(); return app.exec(); } ``` -------------------------------- ### Path Example Source: https://doc.qt.io/qt-6/qml-qtquick-path.html An example demonstrating the usage of the Path QML type within a PathView, including setting start coordinates and defining path elements like PathAttribute and PathQuad. ```APIDOC ## Path Example ``` PathView { anchors.fill: parent model: ContactModel {} delegate: delegate path: Path { startX: 120; startY: 100 PathAttribute { name: "iconScale"; value: 1.0 } PathAttribute { name: "iconOpacity"; value: 1.0 } PathQuad { x: 120; y: 25; controlX: 260; controlY: 75 } PathAttribute { name: "iconScale"; value: 0.3 } PathAttribute { name: "iconOpacity"; value: 0.5 } PathQuad { x: 120; y: 100; controlX: -20; controlY: 75 } } } ``` ``` -------------------------------- ### Basic QCommandLineParser Setup and Option Definition Source: https://doc.qt.io/qt-6/qcommandlineparser.html Demonstrates the basic setup of QCommandLineParser, including setting application name and version, adding help and version options, defining positional arguments, and adding various types of options (boolean, multi-name, with values). ```cpp int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); QCoreApplication::setApplicationName("my-copy-program"); QCoreApplication::setApplicationVersion("1.0"); QCommandLineParser parser; parser.setApplicationDescription("Test helper"); parser.addHelpOption(); parser.addVersionOption(); parser.addPositionalArgument("source", QCoreApplication::translate("main", "Source file to copy.")); parser.addPositionalArgument("destination", QCoreApplication::translate("main", "Destination directory.")); // A boolean option with a single name (-p) QCommandLineOption showProgressOption("p", QCoreApplication::translate("main", "Show progress during copy")); parser.addOption(showProgressOption); // A boolean option with multiple names (-f, --force) QCommandLineOption forceOption(QStringList() << "f" << "force", QCoreApplication::translate("main", "Overwrite existing files.")); parser.addOption(forceOption); // An option with a value QCommandLineOption targetDirectoryOption(QStringList() << "t" << "target-directory", QCoreApplication::translate("main", "Copy all source files into ."), QCoreApplication::translate("main", "directory")); parser.addOption(targetDirectoryOption); // Process the actual command line arguments given by the user parser.process(app); const QStringList args = parser.positionalArguments(); // source is args.at(0), destination is args.at(1) bool showProgress = parser.isSet(showProgressOption); bool force = parser.isSet(forceOption); QString targetDir = parser.value(targetDirectoryOption); // ... } ```