Qt::WA_TranslucentBackground
hmm, still cant seem to get this working, basically i have a screen that i draw, and i need to get ride of a portion of it completely, including that 'white box' that is left behind when i erase rect. I basically want to get ride of that white area and any remnants left over after erasing, so i can see whats behind the application, since my widgets are painted over top of everything else.
(here is my current code for erasing it
painter.eraseRect(0,0,width()/2,height()/2);
this->setBackgroundRole(QPalette::Base);
this->setAttribute(Qt::WA_TranslucentBackground);
Try to test this:
Qt Code:
#include <QtGui> #include <QLabel> //! [main function] int main(int argc, char *argv[]) { f.setPointSize(100); widget.setFont(f); widget.setWindowFlags(Qt::WindowFlags(Qt::FramelessWindowHint)); widget.setAttribute(Qt::WA_TranslucentBackground); widget.show(); return app.exec(); } //! [main function]To copy to clipboard, switch view to plain text mode
this worked and painted text with a transparent background over my windows, allowing me to see behind it where the text was not, but im not sure how to apply this to my problem
Does this help? Use your widget as I have used MyWidget in code below. You don't have to erease anything in your paintEvent
Qt Code:
#include <QtGui> #include <QWidget> { public: protected: }; { p.drawRect(rect()); } //! [main function] int main(int argc, char *argv[]) { MyWidget widget; widget.setFixedSize(300,200); widget.setWindowFlags(Qt::WindowFlags(Qt::FramelessWindowHint)); widget.setAttribute(Qt::WA_TranslucentBackground); widget.show(); return app.exec(); } //! [main function]To copy to clipboard, switch view to plain text mode
I hate attached a small file which hopefully demonstrates what i am trying to do
Qt Code:
{ p.fillRect(rect(), Qt::white); p.drawText(0,0,width(), height(),Qt::AlignCenter || Qt::TextWordWrap, "THIS IS THE AREA WHERE I DRAW IMG"); p.fillRect(rect().adjusted(0,0,-width()/2,-height()/2), Qt::transparent); }To copy to clipboard, switch view to plain text mode
altec42lansing (17th June 2011)
Bookmarks