salmanmanekia
28th May 2008, 08:02
Hi,
I have written a program to show some buttons and use QGraphicsscene and paint class but when i run this program the output is only a 'WHITE BLANK SCREEN '
Below is the implementation of this class and main function,any help/suggestion would be welcome.....pls give it a look !!
int main(int argc,char *argv[])
{
QApplication app(argc, argv);
paintClass paint;
paint.addScene();
paint.setIcons();
paint.drawBGround();
paint.show();
return app.exec();
}
#ifndef PAINTCLASS_H
#define PAINTCLASS_H
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QGraphicsItem>
#include <QGraphicsEllipseItem>
#include <QCursor>
#include <QRectF>
#include <QPushButton>
#include <QGraphicsProxyWidget>
#include <QIcon>
#include <QVBoxLayout>
#include <QPainter>
#include <QWidget>
class paintClass:public QPainter,public QGraphicsView
{
public:
QRectF r1;
QRectF r2;
QGraphicsItem *parent;
QPainter painter;
QGraphicsScene scene;
QWidget *widg ;
QPushButton *stopButton;
QPushButton *playButton;
QHBoxLayout *hLayout;
QGraphicsProxyWidget *proxy;
paintClass(QGraphicsView *parent = 0);
void drawBGround();
void addScene();
void setIcons();
};
#endif
#include "paintClass.h"
paintClass::paintClass(QGraphicsView *parent):QGraphicsView(parent)
{
r1.setRect(100,200,100,160);
r2.setRect(0,0,300,300);
widg = new QWidget;
stopButton = new QPushButton;
playButton = new QPushButton;
hLayout = new QHBoxLayout;
}
void paintClass::drawBGround()
{
painter.setPen(Qt::black);
scene.addText("Hello, world!");
scene.setBackgroundBrush(Qt::blue);
}
void paintClass::addScene()
{
scene.addText("Hello, world!");
hLayout->addWidget(stopButton);
hLayout->addWidget(playButton);
widg->setLayout(hLayout);
scene.addWidget(widg);
}
void paintClass::setIcons()
{
playButton->setIcon(QIcon("./pics/play.JPG"));
stopButton->setIcon(QIcon("./pics/stop.JPG"));
QGraphicsView view(&scene);
}
I have written a program to show some buttons and use QGraphicsscene and paint class but when i run this program the output is only a 'WHITE BLANK SCREEN '
Below is the implementation of this class and main function,any help/suggestion would be welcome.....pls give it a look !!
int main(int argc,char *argv[])
{
QApplication app(argc, argv);
paintClass paint;
paint.addScene();
paint.setIcons();
paint.drawBGround();
paint.show();
return app.exec();
}
#ifndef PAINTCLASS_H
#define PAINTCLASS_H
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QGraphicsItem>
#include <QGraphicsEllipseItem>
#include <QCursor>
#include <QRectF>
#include <QPushButton>
#include <QGraphicsProxyWidget>
#include <QIcon>
#include <QVBoxLayout>
#include <QPainter>
#include <QWidget>
class paintClass:public QPainter,public QGraphicsView
{
public:
QRectF r1;
QRectF r2;
QGraphicsItem *parent;
QPainter painter;
QGraphicsScene scene;
QWidget *widg ;
QPushButton *stopButton;
QPushButton *playButton;
QHBoxLayout *hLayout;
QGraphicsProxyWidget *proxy;
paintClass(QGraphicsView *parent = 0);
void drawBGround();
void addScene();
void setIcons();
};
#endif
#include "paintClass.h"
paintClass::paintClass(QGraphicsView *parent):QGraphicsView(parent)
{
r1.setRect(100,200,100,160);
r2.setRect(0,0,300,300);
widg = new QWidget;
stopButton = new QPushButton;
playButton = new QPushButton;
hLayout = new QHBoxLayout;
}
void paintClass::drawBGround()
{
painter.setPen(Qt::black);
scene.addText("Hello, world!");
scene.setBackgroundBrush(Qt::blue);
}
void paintClass::addScene()
{
scene.addText("Hello, world!");
hLayout->addWidget(stopButton);
hLayout->addWidget(playButton);
widg->setLayout(hLayout);
scene.addWidget(widg);
}
void paintClass::setIcons()
{
playButton->setIcon(QIcon("./pics/play.JPG"));
stopButton->setIcon(QIcon("./pics/stop.JPG"));
QGraphicsView view(&scene);
}