Ben.Hines
26th April 2006, 14:47
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:
QWindowsXPStyle oBaseStyle;
QRadioButton oRadioButton;
QStyleOption oRadioStyleOption;
QSize oNormalRadioSize;
oRadioButton.setStyle(&oBaseStyle);
oRadioButton.ensurePolished();
oRadioStyleOption.initFrom(&oRadioButton);
oNormalRadioSize.setWidth(QWindowsXPStyle::pixelMe tric(PM_ExclusiveIndicatorWidth, &oRadioStyleOption, &oRadioButton));
oNormalRadioSize.setHeight(QWindowsXPStyle::pixelM etric(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::TransparentMod e);
// Draw the radio button into the pixmap.
oRadioPainter.begin(&oRadioPixmap);
oRadioButton.setChecked(true);
oRadioButton.setEnabled(true);
QWindowsXPStyle::drawPrimitive(PE_IndicatorRadioBu tton, &oRadioStyleOption, &oRadioPainter, &oRadioButton);
oRadioPainter.end();
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:
QWindowsXPStyle oBaseStyle;
QRadioButton oRadioButton;
QStyleOption oRadioStyleOption;
QSize oNormalRadioSize;
oRadioButton.setStyle(&oBaseStyle);
oRadioButton.ensurePolished();
oRadioStyleOption.initFrom(&oRadioButton);
oNormalRadioSize.setWidth(QWindowsXPStyle::pixelMe tric(PM_ExclusiveIndicatorWidth, &oRadioStyleOption, &oRadioButton));
oNormalRadioSize.setHeight(QWindowsXPStyle::pixelM etric(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::TransparentMod e);
// Draw the radio button into the pixmap.
oRadioPainter.begin(&oRadioPixmap);
oRadioButton.setChecked(true);
oRadioButton.setEnabled(true);
QWindowsXPStyle::drawPrimitive(PE_IndicatorRadioBu tton, &oRadioStyleOption, &oRadioPainter, &oRadioButton);
oRadioPainter.end();