How to use a theme for my in app/widget in qt embedded, I have follow the following instruction at this url. But it doesn't seem to work not sure why maybe i have missed something
int main(int argc, char *argv[])
{
QString file_path = QCoreApplication::applicationDirPath() + "/theme.css";
QApplication a(argc, argv);
QApplication::setStyle("plastique");
MainWindow w;
QFile style_file(file_path);
if(style_file.open(QIODevice::ReadOnly))
{
qDebug() << "Readin file OK!";
w.setStyleSheet(style_file.readAll());
style_file.close();
}
w.show();
return a.exec();
}
I also have upload the "theme.css" file to the same path, file do exists.
You're supposed to put the content of a stylesheet in QWidget::setStyleSheet
, not a path to a file. So open your file with QFile
, read the contents and set that as your stylesheet.
Here is an example:
QFile style_file("path/to/stylesheet/darkorange.stylesheet");
if(style_file.open(QIODevice::ReadOnly))
this->setStyleSheet(style_file.readAll());