Using theme for my Qt widget application

hlatif

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

Qt dark orange stylesheet

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.

thuga

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());

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Using KDE System Theme in Pure Qt Application

From Dev

Set application theme in Qt

From Dev

A new Qt widget application will not compile

From Dev

Converting my Application Theme to Lollipop

From Dev

Converting my Application Theme to Lollipop

From Dev

Creating a Widget area in my Wordpress Timber Theme

From Dev

Customizing Theme My Login widget on wordpress

From Dev

Use Holo theme in Qt Android application

From Dev

Using Qt Installer Framework to create my Application Installer

From Dev

Qt: Minimize application from child widget

From Dev

Qt: Minimize application from child widget

From Dev

Extensible application using Qt

From Dev

Qt Designer Custom Widget: using flags

From Dev

Qt Designer Custom Widget: using flags

From Dev

QT Widget using OpenCV error deploying to Android

From Dev

Using TextInputLayout layout without changing Application Theme

From Dev

Using Qt codes in Android application

From Dev

Using a dll in a qt application program

From Dev

set size text box and button in Qt Widget Application

From Dev

Qt - How to save data for my application

From Dev

Open and communicate with Excel in my Qt Application

From Dev

Run my application without Qt on linux

From Dev

Packaging my Qt-Binary Application as a Snap

From Dev

My widget doesn't show on the mainwindow. qt

From Dev

Qt Creator doesn't load my custom widget plugin

From Dev

How to get Holo Light theme working in my Xamarin application

From Dev

Can't change colorAccent from my application's theme

From Dev

Change the theme of my whole android studio application confusion

From Dev

Extend Sonar Widget using Iframe into External application

Related Related

HotTag

Archive