Hi Everybody

I have a graphics scene and I need to have some controls on top of it( like buttons ).
This buttons should be static/unmoved while scene scaled, moved, rotated and so on.
So it seems I can not use any kind of graphicitems.

So I decided to create subclass of QWidget

Qt Code:
  1. #include <QPixmap>
  2. #include <QGLWidget>
  3.  
  4. class CLStaticImageWidget : public QGLWidget
  5. {
  6. Q_OBJECT
  7. public:
  8. CLStaticImageWidget(QWidget *parent, QString img, QString name, int max_width);
  9. signals:
  10. void onPressed(QString name);
  11. protected:
  12. void paintEvent(QPaintEvent *event);
  13. protected:
  14. QPixmap m_img;
  15. QString m_name;
  16.  
  17. int m_width;
  18. int m_height;
  19.  
  20. };
To copy to clipboard, switch view to plain text mode 

and cpp file

Qt Code:
  1. CLStaticImageWidget::CLStaticImageWidget(QWidget *parent, QString img, QString name, int max_width):
  2. QGLWidget(parent,0)//, Qt::Window)
  3. {
  4. hide();
  5. m_img = cached(img);
  6.  
  7. int w = m_img.width();
  8. int h = m_img.height();
  9.  
  10. qreal apect = (qreal)w/h;
  11.  
  12. m_width = max_width;
  13. m_height = max_width/apect;
  14.  
  15. QSize size(m_width, m_height);
  16.  
  17. setMaximumSize(size);
  18. setMinimumSize(size);
  19.  
  20. setWindowOpacity(0.5); // here is an issue
  21.  
  22.  
  23.  
  24. }
  25.  
  26. void CLStaticImageWidget::paintEvent(QPaintEvent *event)
  27. {
  28. QPainter painter(this);
  29. painter.drawPixmap(QRect(0,0,m_width,m_height), m_img, m_img.rect());
  30. painter.end();
  31. }
To copy to clipboard, switch view to plain text mode 


and I add it to the scene inside my graphicsview like this

Qt Code:
  1. CLStaticImageWidget * wgt = new CLStaticImageWidget(this, "./skin/home.bmp", "home", 100);
  2. wgt->move(1,1);
  3. wgt->show();
To copy to clipboard, switch view to plain text mode 


So, it works fine except two issues

1) setWindowOpacity does not work. But if widget has flag Qt::Window it works.
Is there any way I can make widget transperent and do not have this Qt::Window flag.

2) If i replace QWidget with QGLWidget and add widget it first dwaws some garbage for a moment(may be something look like part of my desctop or so) and after that works fine.


Any ideas?
Thank you!