PDA

View Full Version : Paint Windows Frames



Iskander
2nd September 2009, 12:30
Hi all. I want to draw my own window frames, as it done in winamp, for example.

I saw documentation for QGraphicsWidget, but I got some problems. First, my window is invisible - may be I should set some WindowFlags in constructor? And the second, setupUI method takes QWidget - so I cannot use QDesigner.

I didnt find something like paintWindowFrame in QWidget.
Is it possible to use QGraphicsProxyWidget here? Can anyone give me a link, how to use it for drawing QWidget's frame?

I can do


Qt::WindowFlags flags = this->windowFlags();
flags |= Qt::SplashScreen;
this->setWindowFlags(flags);

And then draw window borders myself. But in such way, it is nessesary to process all events as move, resize (8 cases!) and so on manually. Is it not complicated, but needs lot of code.

wysota
2nd September 2009, 12:48
It's not possible to paint window decrations using Qt. All you can do is to get rid of the system decorations and emulate all of it yourself.

Iskander
2nd September 2009, 12:55
wysota, thank you.

aamer4yu
2nd September 2009, 13:33
May be this QSkinObject example (http://www.qt-apps.org/content/show.php/QSkinObject?content=67309) help you :)

Iskander
2nd September 2009, 13:40
aamer4yu, thanks, I'll look at it. :)

Iskander
3rd September 2009, 14:06
aamer4yu, I tried to use qskinobject, but when I enable skins in example, widgets start blinking.

I almost finished emulation of moving and resizig, but when Qt::SplashScreen flag, there is no application on a task bar. How to remove system windows decorations, and save precense on a task bar?

NoRulez
3rd September 2009, 15:50
You can inherit from QDialog and overload the paint method.

Best Regards
NoRulez

Iskander
4th September 2009, 04:21
You can inherit from QDialog and overload the paint method.

Best Regards
NoRulez

Of course I inherits from QWidget and all my windows inherts from my "skinned widget". But in paint method it is impossible to draw system windows borders.

wysota
4th September 2009, 08:51
But in paint method it is impossible to draw system windows borders.

Didn't I tell you that like... 7 posts ago? They are called "system borders" for a reason. All you can do is disable them by passing Qt::FramelessWindowHint hint to your widget.

Iskander
4th September 2009, 08:54
Didn't I tell you that like... 7 posts ago?

yes, my previos post was answer for NoRulez.


They are called "system borders" for a reason.

ok :)


All you can do is disable them by passing Qt::FramelessWindowHint hint to your widget.
Yes, I've done it in 0 post. How to stay on a task bar, while setting the flag?

wysota
4th September 2009, 09:00
How to stay on a task bar, while setting the flag?

You can't. At least not without diving into native API although I think in this particular case it wouldn't help.

Iskander
4th September 2009, 09:07
You can't. At least not without diving into native API although I think in this particular case it wouldn't help.

So should I do something like this?


#if defined(Q_WS_WIN)
....
#endif

#if defined(Q_WS_X11)
....
#endif

sadly.

And, as I understand, under linux behaviour depends from current DE settings...

May be it is possible to use QDesktopServices, do you know?

Well, I think about creating a widget out of display region, and in focusInEvent make my "skinned" widget focused, but I think, it's too dirty hack...

wysota
4th September 2009, 09:35
What would desktop services have to do with that? What is exactly that you want to obtain?

Iskander
4th September 2009, 09:57
Sorry for my english.

I want to use my own systems borders(1). So I set Qt::FramelessWindowHint flag.
But there is no my apllication on the task panel in that way.(2)
I want something like winamp - but skin systems does not requiered.
http://s56.radikal.ru/i151/0909/29/af8e3da458a4t.jpg (http://radikal.ru/F/s56.radikal.ru/i151/0909/29/af8e3da458a4.png.html)

I read QDesktopServices docs, and not found anything, relative to my problem, it serves for desctop enviroment, not for task bar, so sorry for my question :)

wysota
4th September 2009, 10:08
Try searching for a solution in WinAPI docs but I doubt you will be able to get the taskbar entry back after disabling system borders. You can try something else though... Don't disable the borders but instead mask them out using QWidget::setMask(). You should not lose the taskbar entry then but the borders wouldn't be visible and you could provide your own ones inside the client area.

Iskander
4th September 2009, 10:30
wysota, thank you! setMask(rect()) works fine!

wysota
5th September 2009, 00:25
wysota, thank you! setMask(rect()) works fine!

Just note that things such as maximizing the window will probably work incorrectly.