Details
-
Suggestion
-
Resolution: Out of scope
-
P4: Low
-
None
-
4.8.5
-
None
-
Windows 7(64 bit)
Description
Here is an example pasted below,
if i tried to draw something on QWidget by overriding the PaintEvent(..) and setting Widget Attribute Qt::WA_Translucent nothing visible on Widget and becomes Complete Transparent as expected but drawing was not visible. i used Qt 4.8.1 & Qt 4.8.5 & Windows 7 (64 bit).
But the same thing without modifying anything i just upgraded the Qt to latest version which is Qt 5.2.1 this example worked fine on the same platform.
// mainwindow.cpp #include "mainwindow.h" #include <QPainter> MainWindow::MainWindow(QWidget *parent) : QWidget(parent) { this->setWindowFlags(this->windowFlags() | Qt::FramelessWindowHint); this->setAttribute(Qt::WA_TranslucentBackground); } MainWindow::~MainWindow() { } void MainWindow::initTimer() { m_timer = new QTimer(); connect(m_timer,SIGNAL(timeout()),this,SLOT(update())); m_timer->start(1000); } void MainWindow::paintEvent(QPaintEvent *pe) { QWidget::paintEvent(pe); QPainter painter(this); painter.beginNativePainting(); QPen pen; pen.setStyle(Qt::SolidLine); pen.setColor(Qt::red); painter.setPen(pen); painter.drawLine(this->rect().topLeft(),this->rect().bottomRight()); painter.endNativePainting(); } // main.cpp #include <QtGui/QApplication> #include "mainwindow.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.resize(500,500); w.initTimer(); w.show(); return a.exec(); }
Attachments
Issue Links
- relates to
-
QTBUG-28531 WA_TranslucentBackground widget issues
- Closed