Thanks a lot, it works fine. With the help of this link and some code from there I came to the following (a bit repeating but more detailed).
1. Find out which style you use:
std::cout << "Default Style: " << app.style()->metaObject()->className() << std::endl;
QApplication app(argc, argv);
std::cout << "Default Style: " << app.style()->metaObject()->className() << std::endl;
To copy to clipboard, switch view to plain text mode
In my case QCleanlooksStyle is used by default.
2. make mystyle.h
#include <QCleanlooksStyle>
{
Q_OBJECT
public:
int pixelMetric
(PixelMetric metric,
const QStyleOption * option
= 0,
const QWidget * widget
= 0 ) const { if (metric
== QStyle::PM_SmallIconSize) { s = 20;
}
return s;
}
};
#include <QCleanlooksStyle>
class MyStyle: public QCleanlooksStyle
{
Q_OBJECT
public:
int pixelMetric(PixelMetric metric, const QStyleOption * option = 0, const QWidget * widget = 0 ) const {
int s = QCleanlooksStyle::pixelMetric(metric, option, widget);
if (metric == QStyle::PM_SmallIconSize) {
s = 20;
}
return s;
}
};
To copy to clipboard, switch view to plain text mode
3. Apply your style to your application
#include "mystyle.h"
...
app.setStyle(new MyStyle);
#include "mystyle.h"
...
QApplication app(argc, argv);
app.setStyle(new MyStyle);
To copy to clipboard, switch view to plain text mode
That's it. If another style is used, e.g. QPlastiqueStyle, replace QCleanlooksStyle with QPlastiqueStyle and it should work as well.
Bookmarks