How to place an widget over the desktop screen using qt
-
i want to place an widget on the screen any where for eg. the way cario dock places it slef or many application places i want to get control at screen.
i am using qt with c++.
please tell the easiest way to do that.
i am developing for desktop using qt widget qt gui -
Looks like you're looking for a toplevel window, maybe some of the convenience classes like QDialog, QMainWindow, etc. are your solution.
-
QDialog, QMainWindow are not the thing of my choice they are windows
have you used cario dock avant dock or any other theere icon does not appear as they open a window they are running and placed at screen positions -
No I didn't, sorry.
-
You might want to post a screenshot or a sketch of what you actually want to achieve. This would help a lot.
-
this is a screen shot which shows an widget placed over screen
http://dl.dropbox.com/u/35031827/toshowhowtoplace.png -
Well, that's quite easy. Just create a frameless, semi-transparent, translucent top-level widget.
@
QWidget *widget = new QWidget;
widget->setAttribute(Qt::WA_TranslucentBackground);
widget->setWindowFlags(Qt::FramelessWindowHint);
widget->setWindowOpacity(0.75);QLabel *label = new QLabel(widget);
label->setFixedSize(640, 480);
label->setStyleSheet("background: black; border-radius: 20px;");widget->show();
@
Be aware that you will still receive event for the non-visible parts of your widget (the remains of the rounded-off corners in this case). If you want to have a truly irregaluar-shaped widget apply an appropriate widget mask using <code>QWidget::setMask()</code>. -
hey lukas i dont want this . this is a window as i window icon appears and i want to do many things like show with graphics when mouse is hovered near and i think i need a graphics item here
-
Just add the <code>Qt::Tool</code> window flag.
@
widget->setWindowFlags(Qt::FramelessWindowHint | Qt::Tool);
@
You cannot just paint to the desktop, you will have to use a window. -
thanks lukas right anwser