PDA

View Full Version : How to sendEvent QPaintEvent ?



SABROG
27th May 2009, 12:24
I want redraw one widget without hi's childs, how to use QProcess::sendEvent with QPaintEvent ? I try this, but this doesn't work:



QPaintEvent *pe = new QPaintEvent(ui->groupBox->rect());
ui->groupBox->setAttribute(Qt::WA_WState_InPaintEvent, true);
QApplication::sendEvent(ui->groupBox, pe);
ui->groupBox->setAttribute(Qt::WA_WState_InPaintEvent, false);


But this code work and i dont' undrestand why:



QPaintEvent *pe = new QPaintEvent(ui->groupBox->rect());
QPixmap pix(ui->groupBox->size());
pix.fill(Qt::white);
QPainter::setRedirected(ui->groupBox, &pix);
QApplication::sendEvent(centralWidget(), pe);
QPainter::restoreRedirected(ui->groupBox);
pix.save("file.jpg");

wysota
27th May 2009, 17:12
What's wrong with calling repaint() or update? The children should be taken from the backing store if they didn't change and their background didn't change.

SABROG
27th May 2009, 17:50
What's wrong with calling repaint() or update? The children should be taken from the backing store if they didn't change and their background didn't change.

I want prevent childrens repaint for overpainting from parent widget. I want change order for repaint recursion. Parent must be last.

wysota
27th May 2009, 20:40
But this will make it paint over the children so you would see nothing. If you really want that have an overlay widget that is transparent and uses QWidget::render() to retrieve a pixmap of the parent and use drawPixmap to paint it on itself.

SABROG
28th May 2009, 06:19
We found other solution.
http://pic.ipicture.ru/uploads/090528/WI6zSKzTKZ.png

installEventFilter for all childs, QApplication::sendEvent in QEvent::Paint for each child.

aamer4yu
28th May 2009, 06:24
From the above pic, how do u expect to work with the combo box ?
Also the hip hop screen looks more like a splash screen :rolleyes:

SABROG
28th May 2009, 06:25
From the above pic, how do u expect to work with the combo box ?
Also the hip hop screen looks more like a splash screen :rolleyes:

Combobox and etc will be over picture, this is true. But i thing this not really matter :)


Also the hip hop screen looks more like a splash screen

Only "looks like", this overpaint for each child.

wysota
28th May 2009, 07:44
Using an overlay this would have been much simpler and quicker in terms of performance :)

Widget Overlay

SABROG
28th May 2009, 08:39
Using an overlay this would have been much simpler and quicker in terms of performance :)

Widget Overlay

I read this page before, but for academic interest i want use only paint features, without any additional widgets. And, unfortunately, i found some things that Qt can't do.
It would be very nice if the QtSoftware will make an additional functionality for such things.

wysota
28th May 2009, 08:49
And, unfortunately, i found some things that Qt can't do.
Ok, such as?

SABROG
28th May 2009, 08:58
Ok, such as?

Like painting over widgets without additional widget and hemorroid with installEventFilter and reimplement paintEvent for all childs. Like create semi-transparent main widget with system titlebar or just titlebar paint from Qt (semi-transparent widget without flag Qt::FramelessWindowHint).

---
More experiments...
http://pic.ipicture.ru/uploads/090528/TqlDA5Ox9X.gif

wysota
28th May 2009, 09:22
Like painting over widgets without additional widget and hemorroid with installEventFilter and reimplement paintEvent for all childs.
I'm sure you'll admit this is not what normally people do :-)

By the way, look here: http://www.qtcentre.org/forum/showthread.php?t=12287&highlight=post+filter


Like create semi-transparent main widget with system titlebar or just titlebar paint from Qt (semi-transparent widget without flag Qt::FramelessWindowHint).

And here: Creating Translucent Windows. For the title bar blame your system - it is not part of the application so it has no control over it.

Any other requests? :-)

SABROG
28th May 2009, 10:57
I'm sure you'll admit this is not what normally people do :-)

By the way, look here: http://www.qtcentre.org/forum/showthread.php?t=12287&highlight=post+filter

Thanks for link, this what we actually doing, but with call QApplication::sendEvent again.



And here: Creating Translucent Windows. For the title bar blame your system - it is not part of the application so it has no control over it.

Any other requests? :-)

With system titelbar i understand. Qt cat draw titlebar from code in QGraphicsWidget for QGraphicsScene. But simple users can't call this painter for Translucent Windows and must write own implementation for this.

--Updated--
I post our solution on wiki.crossplatform.ru (http://translate.google.com/translate?js=n&prev=_t&hl=en&ie=UTF-8&u=http%3A%2F%2Fwiki.crossplatform.ru%2Findex.php%2 F%D0%A0%D0%B8%D1%81%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8% D0%B5_%D0%BF%D0%BE%D0%B2%D0%B5%D1%80%D1%85_%D0%B4% D0%BE%D1%87%D0%B5%D1%80%D0%BD%D0%B8%D1%85_%D0%B2%D 0%B8%D0%B4%D0%B6%D0%B5%D1%82%D0%BE%D0%B2&sl=ru&tl=en&history_state0=&swap=1)

wysota
28th May 2009, 13:12
But simple users can't call this painter for Translucent Windows and must write own implementation for this.
I don't understand what you mean.

SABROG
28th May 2009, 13:42
I try explain. This widget is translucene without system titlebar. What you see - QStyleOptionTitleBar and style()->drawComplexControl(QStyle::CC_TitleBar, &o, &painter, this); (about 115 lines in paintEvent + 138 lines in events like mousePressEvent etc)

http://pic.ipicture.ru/uploads/090528/uX9OjJITdT.png

Why Qt can't draw titlebars for widget outside QGraphicsScene if she can?

wysota
28th May 2009, 13:47
Because the window manager does that. If Qt draws something, it also has to handle it. You don't have things such as system menus or taskbar entries for the windows embedded into Graphics Scene, do you? If you want, you can draw the title bar yourself using QStyle. But it will only look like a title bar, not be one.

SABROG
28th May 2009, 13:57
What i want - just titlebar functionality on translucent widgets. Maybe without system menu etc, but with move widget by mouse and working buttons. Like QMdiSubWindow, but as how MainWindow

wysota
28th May 2009, 14:21
Moving widgets

SABROG
28th May 2009, 14:28
You don't understand me. I write all code myself and he's work. But this huge work and i don't understand why i must do this work if Qt can draw QMdiSubWindow and QGraphicsWidget with titlebar (not system) with full functionality. But Qt don't provide features for creating like this widgets as Main Window, who created how translucene and can't have titlebars.

wysota
28th May 2009, 16:04
Because if it did, you would immediately have asked why the title bar behaved differently that ones from native applications. Qt is not an ultimate solution for everything, it's an application framework. You have the tool - QStyle - use it for non-standard cases and don't expect Trolls to solve all of your problems. If they did, it would be fair if you gave them all the money you earn by writing software. I don't think that is really what you want.

SABROG
28th May 2009, 19:28
Because if it did, you would immediately have asked why the title bar behaved differently that ones from native applications
I don't, i swear. :)


If they did, it would be fair if you gave them all the money you earn by writing software. I don't think that is really what you want.

All already done, just need paint on mainwindow instead QGraphicsWidget. Maybe make feature create QGraphicsWidget outside QGraphicsScene.

wysota
28th May 2009, 20:09
I don't, i swear. :)

Yes, you would. You do it even now. You have translucency yet it is not enough because you wanted translucency and window decorations :cool:


All already done, just need paint on mainwindow instead QGraphicsWidget. Maybe make feature create QGraphicsWidget outside QGraphicsScene.

Yes, and maybe few other things too. Maybe they should even write a class that implements any possible program in the world... Let's be serious now. You want (need) something, do it. You can then share it with others - that's the beauty of Open Source. Don't wait until others do your job for you.

SABROG
28th May 2009, 21:04
Yes, you would. You do it even now. You have translucency yet it is not enough because you wanted translucency and window decorations :cool:

It's becouse this my answer about question what Qt can't do for now, but can internally like QZipReader/QZipWriter (for ODF, but not for .zip archives).



Yes, and maybe few other things too. Maybe they should even write a class that implements any possible program in the world... Let's be serious now. You want (need) something, do it. You can then share it with others - that's the beauty of Open Source. Don't wait until others do your job for you.
I ask, becouse may be i missed something. But thanks anyway.

wysota
28th May 2009, 21:55
If you have some functionality, you will always want more once you start using it. That's perfectly normal and perfectly fine. Let's just remember we're not the only people using the framework and there may be functionality waiting to be implemented that is important for more than <1% of the users and the resources to implement it are limited.