PDA

View Full Version : Customizable widget over main window.



SeeLook
26th March 2012, 09:50
I would like to obtain something (dialog or widget) over main window.
Let's say QWhatsThis is on a half of a way.
I would like to control a time of displaing and also its shape and transparency.

Any hints?

wysota
27th March 2012, 21:00
And what problems are you having?

SeeLook
27th March 2012, 21:49
QWhatsThis depends on an user action - it hides after mouse or key press and it is sqare shaped....

Is some way to subclass something ( Qwidget or Qdialog), put some flags to have control on its transparency, paint something with Qpainter or QgraphicsScene to get something like "comics dialog".
I now only how to remove window decoration from Qdialog but I´m not sure is it good direction to play with some setAttribute() flags.

wysota
27th March 2012, 22:08
You don't need any magic here. You can remove decoration by setting the Qt::FramelessWindowHint hint, you can change the shape of a widget with QWidget::setMask() and you can control the widget's opacity with QWidget::setWindowOpacity() on platforms that support it. You can also use Qt::WA_TranslucentBackground attribute to make a widget semi-transparent.

SeeLook
28th March 2012, 07:29
That was what I need.

Thanks a lot !!!!

SeeLook
23rd June 2012, 16:24
I implemented this by subclassing QDialog.
I added:
Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Tool | Qt::X11BypassWindowManagerHint

when QDialog constructor is called
and also:
setAttribute(Qt::WA_TranslucentBackground, true);

But how to stick this "extra window" to main window of a application.
My way is to reimpement moveEvent() in main window to send signal with moved coefficients,
but still I have to take care of minimizeing of main window - this extra dialog remains over because of Qt::WindowStaysOnTopHint. Yes, I can reimplement some other events from main window

but maybe there is some more smart way