[Qt-interest] Adding a paint event to a Designer widget
Phil
phillor at telstra.com
Wed Dec 24 10:16:03 CET 2008
On Tuesday 23 December 2008 21:45:50 Andreas Pakulat wrote:
>
> No it doesn't. Right-click on an existing widget in designer and choose
> "promote to custom widget", that will allow to choose a name and header
> file. So all you need to have is the header for the custom class available
> when compiling the generated ui_foo.h file.
>
Thank you for your time Andreas, I have always received excellent advice from
you.
Now that I have promoted the frame widget it is no longer displayed on the
main window. I think I understand why but I haven't been able to make the
frame display from my frame class.
The following compiles without error and the paint event is called so I think
I must be close to the answer.
#include "myframe.h"
#include <QtDebug>
MyFrame::MyFrame(QWidget *parent)
: QFrame(parent)
{
/*
The following has been copied from ui_MainWindow.h.
Do I need something like this here?
mapFrame = new MyFrame(centralwidget);
mapFrame->setObjectName(QString::fromUtf8("mapFrame"));
mapFrame->setGeometry(QRect(30, 160, 731, 241));
mapFrame->setFrameShape(QFrame::StyledPanel);
mapFrame->setFrameShadow(QFrame::Raised);
*/
}
MyFrame::~MyFrame()
{
}
void MyFrame::paintEvent(QPaintEvent *)
{
qDebug() << "paint event called" << endl;
QPainter paint(this);
paintMap(&paint);
}
void MyFrame::paintMap(QPainter *p)
{
p->drawText(0,0,"text");
qDebug() << "paint map called" << endl;
}
--
Regards,
Phil.
More information about the Qt-interest-old
mailing list