I had almost the same problem but in my case was with menuItem icons...your solution is possible. But I was recommended to make something like this:
//header
#ifndef ICONSIZE_H
#define ICONSIZE_H
#include <QObject>
#include <QStyle>
#include <QWindowsStyle>
{
Q_OBJECT
public:
int pixelMetric
(PixelMetric metric,
const QStyleOption * option
= 0,
const QWidget * widget
= 0 ) const;
signals:
public slots:
};
#ifndef ICONSIZE_H
#define ICONSIZE_H
#include <QObject>
#include <QStyle>
#include <QWindowsStyle>
class IconSize : public QWindowsStyle
{
Q_OBJECT
public:
explicit IconSize(QWindowsStyle *parent = 0);
int pixelMetric(PixelMetric metric, const QStyleOption * option = 0, const QWidget * widget = 0 ) const;
signals:
public slots:
};
To copy to clipboard, switch view to plain text mode
//CPP
#include "iconsize.h"
{
Q_UNUSED (parent);
}
int IconSize
::pixelMetric(PixelMetric metric,
const QStyleOption * option,
const QWidget * widget
)const {
if (metric
== QStyle::PM_SmallIconSize) { s = 23;
}
return s;
}
#include "iconsize.h"
IconSize::IconSize(QWindowsStyle *parent) :
QWindowsStyle()
{
Q_UNUSED (parent);
}
int IconSize::pixelMetric(PixelMetric metric, const QStyleOption * option, const QWidget * widget)const
{
int s = QWindowsStyle::pixelMetric(metric, option, widget);
if (metric == QStyle::PM_SmallIconSize) {
s = 23;
}
return s;
}
To copy to clipboard, switch view to plain text mode
I reimplemented the necessary methods (in this case only one) of the Windows Style that is the one I use for my application.
Bookmarks