Qt_GUI_BG_7_4 - 8BitsCoding/RobotMentor GitHub Wiki

์˜ˆ์ œ

๋‹ค์Œ๊ณผ ๊ฐ™์ด ๊ฐ„๋‹จํ•˜๊ฒŒ ๋งŒ๋“  ๋‹ค์ด์–ผ๋กœ๊ทธ์— ๋ฆฌ์†Œ์Šค๋ฅผ ํ•˜๋‚˜ ์ถ”๊ฐ€ํ•ด๋ณธ๋‹ค.

ํ•ด๋‹น ํ”„๋กœ์ ํŠธ์— style์ด๋ผ๋Š” ํด๋”๋ฅผ ์ƒ์„ฑ ํ›„ style.cssํŒŒ์ผ์„ ์ƒ์„ฑํ•œ๋‹ค.

์ดํ›„ *.qrc์—์„œ Style.css๋ฅผ ๋ถˆ๋Ÿฌ์˜จ๋‹ค.

์•„๋ž˜ ์ฝ”๋“œ์™€ ๊ฐ™์ด *.css๋ฅผ ์ฝ์–ด์˜จ๋‹ค.

#include "QtGuiApplication3.h"
#include <QtWidgets/QApplication>
#include <qfile.h>
#include <qtextstream.h>
#include <qdebug.h>

QString readTextFile(QString path)
{
	QFile file(path);

	if (file.open(QIODevice::ReadOnly | QIODevice::Text))
	{
		QTextStream in(&file);
		return in.readAll();
	}

	return "";
}

int main(int argc, char *argv[])
{
	QApplication a(argc, argv);

	QString css = readTextFile("./Style/style.css");

	if (css.length() > 0)
	{
		a.setStyleSheet(css);
	}
	else {
		qDebug() << "Error to Read";
	}

	QtGuiApplication3 w;
	w.show();
	return a.exec();
}
QPushButton {
	color : white;
	background-color : red;
}

QPushButton[text="OK"] {
	color : blue;
	background-color : orange;
}

QPushButton#cancel_Button {
	color : black;
	background-color : white;
}

โš ๏ธ **GitHub.com Fallback** โš ๏ธ