Hi,
I'm trying to grab the pixmap for a radio button from the QWindowsXPStyle. I thought that using the style to paint a radio button into a pixmap would work, but I keep getting an empty white square. Any ideas what I'm doing wrong? Here's a code snippet:
oRadioButton.setStyle(&oBaseStyle);
oRadioButton.ensurePolished();
oRadioStyleOption.initFrom(&oRadioButton);
oNormalRadioSize.
setWidth(QWindowsXPStyle::pixelMetric(PM_ExclusiveIndicatorWidth,
&oRadioStyleOption,
&oRadioButton
));
oNormalRadioSize.
setHeight(QWindowsXPStyle::pixelMetric(PM_ExclusiveIndicatorHeight,
&oRadioStyleOption,
&oRadioButton
));
// Initialize a painter and pixmap for drawing the radio buttons
// at their normal sizes.
QPixmap oRadioPixmap
(oNormalRadioSize
);
oRadioPainter.setBackgroundMode(Qt::TransparentMode);
// Draw the radio button into the pixmap.
oRadioPainter.begin(&oRadioPixmap);
oRadioButton.setChecked(true);
oRadioButton.setEnabled(true);
QWindowsXPStyle::drawPrimitive(PE_IndicatorRadioButton,
&oRadioStyleOption,
&oRadioPainter,
&oRadioButton
);
oRadioPainter.end();
QWindowsXPStyle oBaseStyle;
QRadioButton oRadioButton;
QStyleOption oRadioStyleOption;
QSize oNormalRadioSize;
oRadioButton.setStyle(&oBaseStyle);
oRadioButton.ensurePolished();
oRadioStyleOption.initFrom(&oRadioButton);
oNormalRadioSize.setWidth(QWindowsXPStyle::pixelMetric(PM_ExclusiveIndicatorWidth, &oRadioStyleOption, &oRadioButton));
oNormalRadioSize.setHeight(QWindowsXPStyle::pixelMetric(PM_ExclusiveIndicatorHeight, &oRadioStyleOption, &oRadioButton));
// Initialize a painter and pixmap for drawing the radio buttons
// at their normal sizes.
QPixmap oRadioPixmap(oNormalRadioSize);
QPainter oRadioPainter;
oRadioPainter.setBackgroundMode(Qt::TransparentMode);
// Draw the radio button into the pixmap.
oRadioPainter.begin(&oRadioPixmap);
oRadioButton.setChecked(true);
oRadioButton.setEnabled(true);
QWindowsXPStyle::drawPrimitive(PE_IndicatorRadioButton, &oRadioStyleOption, &oRadioPainter, &oRadioButton);
oRadioPainter.end();
To copy to clipboard, switch view to plain text mode
Bookmarks