gqtbuttonswidget
Loading...
Searching...
No Matches
gqtbuttons_example.cc
Go to the documentation of this file.
1
25#include "gQtButtonsWidget.h"
26
27// qt
28#include <QApplication>
29#include <QMainWindow>
30#include <QTimer>
31
53int main(int argc, char* argv[]) {
54 // Initialize options and logging.
55 // Note: "hello" is the example's program name used by GOptions.
56 auto gopts = std::make_shared<GOptions>(argc, argv, GOptions("hello"));
57
58 // Example switches/scalars expected to exist in the calling environment.
59 // If not provided, GOptions will use its internal defaults.
60 auto gui = gopts->getSwitch("gui");
61 auto timeout = gopts->getScalarDouble("tt");
62 int ret = EXIT_SUCCESS;
63
64 // Create a QApplication only when GUI mode is enabled.
65 QApplication* app = nullptr;
66 if (gui) {
67 app = new QApplication(argc, argv);
68 }
69
70 // Icon base names:
71 // The resource path must match the path used in the module's .qrc file.
72 std::vector<std::string> bicons;
73 bicons.emplace_back(":/images/firstButton");
74 bicons.emplace_back(":/images/secondButton");
75
76 if (gui) {
77 // Create and show the icon-based buttons widget.
78 GQTButtonsWidget window(128, 128, bicons);
79 window.show();
80
81 // Quit after the requested timeout (milliseconds).
82 QTimer::singleShot(timeout, [] {
83 QCoreApplication::quit(); // stops the event loop
84 });
85
86 ret = QApplication::exec();
87
88 // Clean up GUI resources.
89 delete app;
90 }
91 else {
92 // CLI mode:
93 // This example intentionally does not execute any non-GUI behavior.
94 }
95
96 return ret;
97}
Icon-based button strip widget implemented using a QListWidget.
Options definition entry point for the Qt Buttons Widgets module.
int main(int argc, char *argv[])