linus
16th March 2010, 12:15
Hi!
Om working on a project thats showing a mpeg-file using phonon. I would like to place a transparent QWidget over my video so i can click and paint on it. I managed to put a QWidget above the video and i can click with the mouse and paint on it but its not transparent.
Any ideas how to make it transparent?
Heres my Overlay QWidget:
#include <QtGui>
#include "videoarea.h"
VideoArea::VideoArea(QWidget *parent) :
QWidget(parent)
{
this->setWindowOpacity(1.0);
}
void VideoArea::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
qDebug("Mouse click: X: %d Y: %d", event->x(), event->y());
crossList.append(QPoint(event->x(), event->y()));
paintCross();
}
}
void VideoArea::paintCross()
{
update();
}
void VideoArea::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.setPen(QPen(Qt::red, 1, Qt::DashDotLine, Qt::RoundCap));
for (int i = 0; i < crossList.size(); ++i)
{
painter.drawLine(crossList.at(i).x(), crossList.at(i).y()+10, crossList.at(i).x(), crossList.at(i).y()-10);
painter.drawLine(crossList.at(i).x()+10, crossList.at(i).y(), crossList.at(i).x()-10, crossList.at(i).y());
}
}
Om working on a project thats showing a mpeg-file using phonon. I would like to place a transparent QWidget over my video so i can click and paint on it. I managed to put a QWidget above the video and i can click with the mouse and paint on it but its not transparent.
Any ideas how to make it transparent?
Heres my Overlay QWidget:
#include <QtGui>
#include "videoarea.h"
VideoArea::VideoArea(QWidget *parent) :
QWidget(parent)
{
this->setWindowOpacity(1.0);
}
void VideoArea::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
qDebug("Mouse click: X: %d Y: %d", event->x(), event->y());
crossList.append(QPoint(event->x(), event->y()));
paintCross();
}
}
void VideoArea::paintCross()
{
update();
}
void VideoArea::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.setPen(QPen(Qt::red, 1, Qt::DashDotLine, Qt::RoundCap));
for (int i = 0; i < crossList.size(); ++i)
{
painter.drawLine(crossList.at(i).x(), crossList.at(i).y()+10, crossList.at(i).x(), crossList.at(i).y()-10);
painter.drawLine(crossList.at(i).x()+10, crossList.at(i).y(), crossList.at(i).x()-10, crossList.at(i).y());
}
}