How to create a QT plugin that customizes UI?

We would want the users to be able to optionally customize our QT applications. So if they would want to create their own theme for our applications, all they have to do is load their own CSS file.

Do we really need to create a plugin to be able to do that? If yes, could somebody give me the basic steps/ or a jump start on how to do it? If no, are there features in QT that I need to know to be able to do that without creating a plugin?

Answers


I have a Jabber instant messenger which is plugin based and written in Qt. It includes a style plugin that does exactly what you describe. The source for that plugin is here:

https://github.com/sje397/saje/tree/master/plugins/styles/

(Note: this is a plugin for my application - not a 'Qt style plugin')

Basically all you need to do is load a style sheet and call QApplication::setStyleSheet:

QFile f("filename");
if(f.open(QIODevice::ReadOnly)) {
    qApp->setStyleSheet(f.readAll());
}

An example of a valid style sheet is here. Note that it is for my app, so includes some of my own class names etc.


Need Your Help

Cannot close window without process associated

windows visual-studio process handle terminate

I'm writing and then debugging a console application in VC++ 2008, it then happens that closing Visual Studio IDE, the console window remain opened, and there is no way to close it!

Performance difference between IIf() and If

vb.net if-statement iif-function

In Visual Basic, is there a performance difference when using the IIf function instead of the If statement?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.