$ ps -o pid,rss,command -p $(pgrep -f SimpleQtApp)
PID RSS COMMAND
1471929 33052 ./SimpleQtApp
$ ps -o pid,rss,command -p $(pgrep -f SimpleQmlApp)
1478335 123260 ./SimpleQmlApp
// Following is the simple Qt app code.
#include <QApplication>
#include <QWidget>
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>
int main(int argc, char argv[]) {
QApplication app(argc, argv); QWidget window; window.setWindowTitle("Qt Simple App (CMake)"); window.resize(300, 150); QLabel *label = new QLabel("Hello, World!", &window); label->setAlignment(Qt::AlignCenter); QPushButton *button = new QPushButton("Click Me", &window); QVBoxLayout *layout = new QVBoxLayout(&window); layout->addWidget(label); layout->addWidget(button); QObject::connect(button, &QPushButton::clicked, [label]() { label->setText("You clicked the button!"); }); window.show(); return app.exec();
// Following is the QML app code
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[]) {
QGuiApplication app(argc, argv); QQmlApplicationEngine engine; const QUrl url(QStringLiteral("qrc:/Main.qml")); QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed, &app, []() { QCoreApplication::exit(-1); }, Qt::QueuedConnection); engine.load(url); return app.exec();
// Main.qml
import QtQuick
import QtQuick.Controls
Window {
width: 320 height: 200 visible: true title: "Simple QML Application" Column { anchors.centerIn: parent spacing: 20 Label { id: statusLabel text: "Hello, QML World!" font.pointSize: 16 anchors.horizontalCenter: parent.horizontalCenter } Button { text: "Click Me" anchors.horizontalCenter: parent.horizontalCenter // Handle click event inline onClicked: { statusLabel.text = "You clicked the QML button!" } } } }
$ ps -o pid,rss,command -p $(pgrep -f SimpleQtApp)
PID RSS COMMAND
1471929 33052 ./SimpleQtApp
$ ps -o pid,rss,command -p $(pgrep -f SimpleQmlApp)
PID RSS COMMAND
1478335 123260 ./SimpleQmlApp
// Following is the simple Qt app code.
#include <QApplication>
#include <QWidget>
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>
int main(int argc, char argv[]) {
}// Following is the QML app code
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[]) {
}// Main.qml
import QtQuick
import QtQuick.Controls
Window {