PDA

View Full Version : Styles - building



Salazaar
17th May 2007, 17:06
Hi. I've gotta question. How can I build (not launch) program in plastique style?

wysota
17th May 2007, 17:08
You can't "build" an application in particular style. You can just use QApplication::setStyle() to force a style in your application.

Salazaar
17th May 2007, 17:11
Can I do it in designer? If not, how can I set style to application which code was created by designer?

wysota
17th May 2007, 17:17
As I said - use QApplication::setStyle in your code (for example in main()) and make sure you do it before creating QApplication instance so that the user can override your choice by using the -style switch.

Salazaar
17th May 2007, 17:53
Hmm...I don't understand...How can I do it in my case? My main.cpp file:

#include <QApplication>

#include "maker.h"

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MainWindow MainWindow;
MainWindow.show();
return app.exec();
}

marcel
17th May 2007, 18:11
Hmm...I don't understand...How can I do it in my case? My main.cpp file:

#include <QApplication>

#include "maker.h"

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MainWindow MainWindow;
MainWindow.show();
return app.exec();
}



Call QApplication::setStyle ( new QPlastiqueStyle() ) in main, just before creating QApplication.

Salazaar
17th May 2007, 18:14
#include <QApplication>

#include "maker.h"

int main(int argc, char *argv[])
{
QApplication::setStyle ( new QPlastiqueStyle() )
QApplication app(argc, argv);
MainWindow MainWindow;
MainWindow.show();
return app.exec();
}
is that correct?

marcel
17th May 2007, 18:20
Yes. Don't forget ; after the line you just added, and aslo include <QPlastiqueStyle>.

Regards

Salazaar
17th May 2007, 18:54
thanks for a tip

wysota
17th May 2007, 20:26
I'm sorry, but I just can't resist myself from asking... What are your C++ skills?

Salazaar
20th May 2007, 18:19
I'm just a bit scatterbrained ;)