Answer the question
In order to leave comments, you need to log in
How to include a qss stylesheet?
Hello everyone! With coming!
I'm trying to make a single stylesheet for a QT 5.7 Widgets program.
I do according to the instructions: Link
I have a QTabBar. The object name is myTabWidget.
I'm trying to do like this:
QFile styleFile(":/qss/style.qss");
styleFile.open(QFile::ReadOnly);
QString styleSheet = QString::fromLatin1( styleFile.readAll() );
styleFile.close();
ui->myTabWidget->setStyleSheet(styleSheet);
ui->myTabWidget->setStyleSheet("QTabBar::tab:first { border-top: none; }");
Answer the question
In order to leave comments, you need to log in
I did this (it really was a long time ago, maybe it needs to be corrected in the current version of Qt):
int main(int argc, char** argv)
{
QApplication app(argc, argv);
QFile file(":/qss/stylesheet.qss");
file.open(QFile::ReadOnly);
app.setStyleSheet(file.readAll());
bool ok = app.exec();
return ok;
}
QTabWidget {
background-color: #999999;
}
Вы уверены, что кодировка таблицы стилей latin1?
Я бы использовал QString::fromUtf8
.
Закрывать файл, насколько я понимаю, не надо.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question