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";
}

이미지

⚠️ **GitHub.com Fallback** ⚠️