PDA

View Full Version : Repaint Widget in an other



hubert_p
6th November 2006, 08:11
Hi,
I actually try to repaint a widget with an other widget, but it seems that not work. So, perhaps I'm in a wrong way about how to use that.
The code is really simple


void
QpulsarPopupEditorContainer::paintEvent(QPaintEven t *event)
{
// m_waitEditor, QWidget that contain a QLabel with text
if(m_waitEditor)
{
QPaintEngine *l_paintEngine =m_waitEditor->paintEngine();
QPainter *l_painter = l_paintEngine->painter();
}
else
QWidget::paintEvent(event);
}


Does anyone have a solution ?

Thanks in advance

Philippe

jpn
6th November 2006, 08:59
How about:


m_waitEditor->update(); // schedules a paint event

hubert_p
6th November 2006, 09:13
That not work in my case, the problem is that I try to get the painter from a widget and putting it in an other.
When I arrive in the paint event, it display nothing. I think that my problem is in my paintEvent but I don't no what !

Philippe

jpn
6th November 2006, 10:01
What is it you are actually trying to achieve? Maybe there's a better way.. ;) In Qt4 you cannot paint outside paintEvent(). See notes about Qt::WA_PaintOutsidePaintEvent (http://doc.trolltech.com/4.2/qt.html#WidgetAttribute-enum).

hubert_p
6th November 2006, 10:09
I do not try to paint outside, the problem is, when I paint in the paint event, I only have an empty widget. I try to use drawText and the result is the same.
Perhaps there is a better way, but for now, I do not see which way

Philippe

wysota
6th November 2006, 10:18
Maybe using QPainter::setRedirected()?

hubert_p
6th November 2006, 11:54
No, the problem stay.
I try to find if I can find an other solution with QWidget::stackUnder() but it seems that was no the solution too.

jpn
6th November 2006, 12:12
How did you use the redirecting?



QPainter::setRedirected(m_waitEditor, this);
QPaintEvent event(m_waitEditor->rect());
QApplication::sendEvent(m_waitEditor, &event);
QPainter::restoreRedirected(m_waitEditor);