Hi, I have
#ifndef MYCUSTOMFRAME_H
#define MYCUSTOMFRAME_H
#include "baseform.h"
#include <qframe.h>
#include <qpainter.h>
class MyCustomFrame
: public QFrame{
Q_OBJECT
protected:
};
{
painter.drawLine(0, 0, 200, 150);
}
#endif // MYCUSTOMFRAME_H
#ifndef MYCUSTOMFRAME_H
#define MYCUSTOMFRAME_H
#include "baseform.h"
#include <qframe.h>
#include <qpainter.h>
class MyCustomFrame : public QFrame
{
Q_OBJECT
protected:
void paintEvent(QPaintEvent* event);
};
void MyCustomFrame::paintEvent(QPaintEvent* event)
{
QPainter painter(this);
painter.drawLine(0, 0, 200, 150);
}
#endif // MYCUSTOMFRAME_H
To copy to clipboard, switch view to plain text mode
and it compiles with out errors or warnings.
I have 2 quentions:
1. How do I access it from the body of my program as I was required to remove "#include "mycustomframe.h" from "baseform.cpp"?
2. I have a class "drawingfunctions.h" where I would like to do the painting. If I read you correctly, I need to change the class name from
class DrawingFunctions
: public QWidget{
Q_OBJECT
public:
class DrawingFunctions : public QWidget
{
Q_OBJECT
public:
To copy to clipboard, switch view to plain text mode
to
class DrawingFunctions
: public QFrame{
Q_OBJECT
public:
DrawingFunctions
( QWidget *parent
= 0 );
class DrawingFunctions : public QFrame
{
Q_OBJECT
public:
DrawingFunctions( QWidget *parent = 0 );
To copy to clipboard, switch view to plain text mode
and i think the "parent = 0" is wrong.
And what do I need to change here?
DrawingFunctions
::DrawingFunctions( QWidget *parent
) : QWidget(parent
)
DrawingFunctions::DrawingFunctions( QWidget *parent ) : QWidget(parent)
To copy to clipboard, switch view to plain text mode
As you can tell, i have no clear understanding of whats going on. I am able to use QTextEdit widgets on my base QFrame, but not the QPainter.
(These "uncontrolled" events of Qt4 are driving me up a wall.)
I really appreciate your patience with me.
Bookmarks