brazso
18th August 2010, 14:13
Hello,
I try to overwrite a bigger project from Qt3 to Qt4 and there is problem with the method of QLabel::drawContents. I know that drawContents was exiled from Qt4, and the proposed replacement is the usage of paintEvent(QPaintEvent*). I'm confused about replacing a draw function with an event. I suppose at first I have to implement the paintEvent in my class, then I have to call it with (QWidget:: ) update or repaint methods.
In my exact case there is a new class named ButtonPreview inherited from QLabel. (It is defined as virtual protected in the header file.) Its implementation looks like this in Qt3:
void ButtonPreview::drawContents(QPainter *painter)
{
QLabel::drawContents(painter);
// ... additional drawing
}
I suppose QLabel :: drawContents does nothing but I do not want to remove that line, it would be too simple :)
I wish to invoke QLabel :: paintEvent. Do I alter drawContents(painter) to "update" or "repaint"? I'm afraid I have to use "repaint" here, paintEvent must be executed immediately and synchronously before the execution of "additional drawing" part.
The ugliest case is if I have to create ButtonPreview :: paintEvent too with the content of ButtonPreview :: drawContents.
Brazso
I try to overwrite a bigger project from Qt3 to Qt4 and there is problem with the method of QLabel::drawContents. I know that drawContents was exiled from Qt4, and the proposed replacement is the usage of paintEvent(QPaintEvent*). I'm confused about replacing a draw function with an event. I suppose at first I have to implement the paintEvent in my class, then I have to call it with (QWidget:: ) update or repaint methods.
In my exact case there is a new class named ButtonPreview inherited from QLabel. (It is defined as virtual protected in the header file.) Its implementation looks like this in Qt3:
void ButtonPreview::drawContents(QPainter *painter)
{
QLabel::drawContents(painter);
// ... additional drawing
}
I suppose QLabel :: drawContents does nothing but I do not want to remove that line, it would be too simple :)
I wish to invoke QLabel :: paintEvent. Do I alter drawContents(painter) to "update" or "repaint"? I'm afraid I have to use "repaint" here, paintEvent must be executed immediately and synchronously before the execution of "additional drawing" part.
The ugliest case is if I have to create ButtonPreview :: paintEvent too with the content of ButtonPreview :: drawContents.
Brazso