anjinkristou

Window overlay

Feb 7th, 2014
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class DiagnosticStyle : public QWindowsVistaStyle
  2. {
  3. Q_OBJECT
  4.  
  5. public:
  6.     typedef QWindowsVistaStyle BaseStyle;
  7.     void drawControl(ControlElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget) const;
  8. };
  9.  
  10.  
  11. void DiagnosticStyle::drawControl(ControlElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget) const
  12. {
  13.     BaseStyle::drawControl(element, option, painter, widget);
  14.     if (widget && painter) {
  15.         // draw a border around the widget
  16.         painter->setPen(QColor("red"));
  17.         painter->drawRect(widget->rect());
  18.  
  19.         // show the classname of the widget
  20.         QBrush translucentBrush(QColor(255,246,240, 100));
  21.         painter->fillRect(widget->rect(), translucentBrush);
  22.         painter->setPen(QColor("darkblue"));
  23.         painter->drawText(widget->rect(), Qt::AlignLeft | Qt::AlignVCenter, widget->metaObject()->className());
  24.     }
  25. }
  26.  
  27. qApp->setStyle(new DiagnosticStyle());
  28. improve this question
Advertisement
Add Comment
Please, Sign In to add comment