Qt_Core_AD_5_1 - 8BitsCoding/RobotMentor GitHub Wiki
μλλ
QTest::qExec
μ μ¬μ©λ²μ λν΄ μ€λͺ νκ³QTest::qExec
μ ν΄λΉQObject
μprivate slots
λ₯Ό ν μ€ν ν΄μ€λ€. λ¨, λ§€κ°λ³μκ° μμκ²½μ° ν μ€ν μ΄ λΆκ°!
// main.cpp
#include <QtCore/QCoreApplication>
#include <qtest.h>
#include "cat.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
cat c;
QTest::qExec(&c);
return a.exec();
}
#pragma once
#include <QObject>
#include <qdebug.h>
class cat : public QObject
{
Q_OBJECT
public:
explicit cat(QObject *parent = nullptr);
~cat();
signals:
public slots:
void test();
private slots:
void meow();
void sleep();
void speak(QString value); // did not call due to param
};
#include "cat.h"
cat::cat(QObject *parent)
: QObject(parent)
{
}
cat::~cat()
{
}
void cat::speak(QString value)
{
qInfo() << "speak" << value;
}
void cat::meow()
{
qInfo() << "meow";
}
void cat::sleep()
{
qInfo() << "sleep";
}
void cat::test()
{
qInfo() << "test";
}