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