Qt Multi-Window Utility Architecture
This implementation leverages Qt's signal-slot mechanism to construct a dual-tool system featuring a mathematical calculator and a mouse auto-clicker. The structure comprises three distinct views: a central launcher, the calculator interface, and the auto-clicker interface.
Executable and Window Icon Configuration
To assign an executable icon (e.g., app_icon.ico) located outside the resource system, add the following line to the .pro build configuration: RC_ICONS = assets/app_icon.ico. Unless a specific window icon is explicitly set for a view, the application icon serves as the default title bar icon for all derived windows. Window icons also accept standard image formats.
Application Entry Point
The main routine initializes the primary controller window.
#include <QApplication>
#include "launcherwindow.h"
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
LauncherWindow launcher;
launcher.show();
return app.exec();
}
Launcher Controller Definition
The central launcher header declares instances of the secondary tool interfaces.
#ifndef LAUNCHERWINDOW_H
#define LAUNCHERWINDOW_H
#include <QWidget>
#include "calcwindow.h"
#include "autoclickerwindow.h"
class LauncherWindow : public QWidget {
Q_OBJECT
public:
LauncherWindow(QWidget *parent = nullptr);
~LauncherWindow();
private:
CalcWindow *m_calc;
AutoClickerWindow *m_clicker;
};
#endif // LAUNCHERWINDOW_H
Pointer members m_calc and m_clicker represent the sub-windows, ensuring proper memory management and deferred instantiation.
Launcher UI and Signal Binding
The launcher implementation configures the background, creates navigation buttons, and routes click events to the sub-window display slots.
#include "launcherwindow.h"
#include <QPushButton>
#include <QVBoxLayout>
#include <QPixmap>
#include <QPalette>
LauncherWindow::LauncherWindow(QWidget *parent) : QWidget(parent) {
setAutoFillBackground(true);
QPalette bgPalette;
QPixmap bgImage(":/images/main_bg.jpg");
bgPalette.setBrush(QPalette::Window, QBrush(bgImage));
setPalette(bgPalette);
setWindowTitle("Tool Suite");
setFixedSize(500, 400);
m_calc = new CalcWindow();
m_clicker = new AutoClickerWindow();
QPushButton *btnCalc = new QPushButton("Open Calculator");
QPushButton *btnClicker = new QPushButton("Open Auto-Clicker");
btnCalc->setFixedSize(120, 60);
btnClicker->setFixedSize(120, 60);
QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->addWidget(btnCalc);
vbox->addWidget(btnClicker);
vbox->setContentsMargins(20, 20, 20, 20);
setLayout(vbox);
connect(btnCalc, &QPushButton::clicked, m_calc, &CalcWindow::show);
connect(btnClicker, &QPushButton::clicked, m_clicker, &AutoClickerWindow::show);
}
Directly connecting the clicked signal to the inherited show slot of each sub-window provides a clean, reusable pattern for toggling window visibility without requiring custom wrapper methods.