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:
Qt Code:
  1. QWindowsXPStyle oBaseStyle;
  2. QRadioButton oRadioButton;
  3. QStyleOption oRadioStyleOption;
  4. QSize oNormalRadioSize;
  5. oRadioButton.setStyle(&oBaseStyle);
  6. oRadioButton.ensurePolished();
  7. oRadioStyleOption.initFrom(&oRadioButton);
  8. oNormalRadioSize.setWidth(QWindowsXPStyle::pixelMetric(PM_ExclusiveIndicatorWidth, &oRadioStyleOption, &oRadioButton));
  9. oNormalRadioSize.setHeight(QWindowsXPStyle::pixelMetric(PM_ExclusiveIndicatorHeight, &oRadioStyleOption, &oRadioButton));
  10.  
  11.  
  12. // Initialize a painter and pixmap for drawing the radio buttons
  13. // at their normal sizes.
  14. QPixmap oRadioPixmap(oNormalRadioSize);
  15. QPainter oRadioPainter;
  16. oRadioPainter.setBackgroundMode(Qt::TransparentMode);
  17.  
  18. // Draw the radio button into the pixmap.
  19. oRadioPainter.begin(&oRadioPixmap);
  20. oRadioButton.setChecked(true);
  21. oRadioButton.setEnabled(true);
  22. QWindowsXPStyle::drawPrimitive(PE_IndicatorRadioButton, &oRadioStyleOption, &oRadioPainter, &oRadioButton);
  23. oRadioPainter.end();
To copy to clipboard, switch view to plain text mode