Hi,
inspired by k3b osd I have added to my application an osd widget; now it works good in linux but in windows the widget decoration (borders) is visible. Here is the code I have used:
Qt Code:
  1. GmckJobProgressOSD::GmckJobProgressOSD( QWidget* parent )
  2. : QWidget( parent, Qt::Window | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint ),
  3. m_dirty(true),
  4. m_progress(0),
  5. m_dragging(false),
  6. m_screen(0),
  7. m_position(s_outerMargin, s_outerMargin)
  8. {
  9. QPixmap pix(10,10);
  10. m_osdBuffer = pix;
  11. setFocusPolicy( Qt::NoFocus );
  12.  
  13. // dummy size
  14. resize( 100, 20 );
  15. }
  16.  
  17.  
  18. void GmckJobProgressOSD::renderOSD()
  19. {
  20. // -----------------------------------------
  21. // | download |
  22. // | GMCK ========== 40% |
  23. // | |
  24. // -----------------------------------------
  25.  
  26. // calculate needed size
  27. if( true ) {
  28. QPixmap icon(":/icons/icon16x16.png");
  29. int margin = 10;
  30. int textWidth = fontMetrics().width( m_text );
  31.  
  32. // do not change the size every time the text changes, just in case we are too small
  33. QSize newSize( qMax( qMax( 2*margin + icon.width() + margin + textWidth, 100 ), width() ),
  34. qMax( 2*margin + icon.height(), 2*margin + fontMetrics().height()*2 ) );
  35.  
  36. m_osdBuffer = m_osdBuffer.scaled( newSize );
  37. QPainter p( &m_osdBuffer );
  38.  
  39. p.setPen( Qt::white );
  40.  
  41. // draw the background and the frame
  42. QRect thisRect( -1, -1, newSize.width()+1, newSize.height()+1 );
  43. p.fillRect( thisRect, QColor(233,116,37));
  44. p.drawRect( thisRect );
  45.  
  46. // draw the gmck icon
  47. p.drawPixmap( margin, (newSize.height()-icon.height())/2, icon );
  48.  
  49. // draw the text
  50. QSize textSize = fontMetrics().size( 0, m_text );
  51. int textX = 2*margin + icon.width();
  52. int textY = margin + fontMetrics().ascent();
  53. p.drawText( textX, textY, m_text );
  54.  
  55. // draw the progress
  56. textY += fontMetrics().descent() + 4;
  57. QRect progressRect( textX, textY, newSize.width()-textX-margin, newSize.height()-textY-margin );
  58. p.drawRect( progressRect );
  59. progressRect.setWidth( m_progress > 0 ? m_progress*progressRect.width()/100 : 0 );
  60. p.fillRect( progressRect, Qt::white );
  61.  
  62. // reposition the osd
  63. reposition( newSize );
  64. resize(newSize);
  65.  
  66. m_dirty = false;
  67.  
  68. update();
  69. }
  70. }
  71.  
  72.  
  73. void GmckJobProgressOSD::paintEvent( QPaintEvent* )
  74. {
  75. QPainter *p = new QPainter(this);
  76. p->drawPixmap(0,0,m_osdBuffer);
  77. }
To copy to clipboard, switch view to plain text mode 

Can I obtain the same aspect in windows too? How?

Thanks