QWidget/QGlwidget ( + window opacity )
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
Code:
#include <QPixmap>
#include <QGLWidget>
{
Q_OBJECT
public:
signals:
protected:
protected:
int m_width;
int m_height;
};
and cpp file
Code:
{
hide();
m_img = cached(img);
int w = m_img.width();
int h = m_img.height();
qreal apect = (qreal)w/h;
m_width = max_width;
m_height = max_width/apect;
QSize size
(m_width, m_height
);
setMaximumSize(size);
setMinimumSize(size);
setWindowOpacity(0.5); // here is an issue
}
void CLStaticImageWidget
::paintEvent(QPaintEvent *event
) {
painter.
drawPixmap(QRect(0,
0,m_width,m_height
), m_img, m_img.
rect());
painter.end();
}
and I add it to the scene inside my graphicsview like this
Code:
CLStaticImageWidget * wgt = new CLStaticImageWidget(this, "./skin/home.bmp", "home", 100);
wgt->move(1,1);
wgt->show();
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!