Hi..
I had tried to show a layout of buttons on View..it worked fine,but the return function ( retWidg() ) which i have specified in the main doesnt seems to be necessary..i mean to say is there any other solution by which i can avoid these statement and with it be more cleared in approach...
#include "exclass.h"
#include <QApplication>
#include <QGraphicsScene>
int main(int argc, char *argv[])
{
exclass *w = new exclass;
mainW = w->retWidg();
scene.addWidget(mainW);
scene.addItem(w);
view.setScene(&scene);
view.show();
return a.exec();
}
#ifndef EXCLASS_H
#define EXCLASS_H
#include <QtGui/QWidget>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QGraphicsItem>
#include <QPainter>
#include <QImage>
#include <QPushButton>
#include <QHBoxLayout>
//#include <QString>
//#include "ui_exclass.h"
{
Q_OBJECT
public:
};
#endif // EXCLASS_H
#include "exclass.h"
{
hboxLay->addWidget(playButton);
hboxLay->addWidget(stopButton);
widg->setLayout(hboxLay);
}
{
return widg;
}
QRectF exclass
::boundingRect() const {
}
{
}
#include "exclass.h"
#include <QApplication>
#include <QGraphicsScene>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
exclass *w = new exclass;
QWidget *mainW = new QWidget;
QGraphicsScene scene;
QGraphicsView view;
mainW = w->retWidg();
scene.addWidget(mainW);
scene.addItem(w);
view.setScene(&scene);
view.show();
return a.exec();
}
#ifndef EXCLASS_H
#define EXCLASS_H
#include <QtGui/QWidget>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QGraphicsItem>
#include <QPainter>
#include <QImage>
#include <QPushButton>
#include <QHBoxLayout>
//#include <QString>
//#include "ui_exclass.h"
class exclass :public QObject, public QGraphicsItem
{
Q_OBJECT
public:
QPushButton *stopButton;
QPushButton *playButton;
QHBoxLayout *hboxLay;
QWidget *widg;
exclass(QGraphicsItem *parent = 0);
QWidget *retWidg();
QRectF boundingRect() const;
void paint(QPainter *painter,const QStyleOptionGraphicsItem *option,QWidget *widget);
};
#endif // EXCLASS_H
#include "exclass.h"
exclass::exclass(QGraphicsItem *parent):QGraphicsItem(parent)
{
hboxLay = new QHBoxLayout;
playButton = new QPushButton;
stopButton = new QPushButton;
widg = new QWidget;
hboxLay->addWidget(playButton);
hboxLay->addWidget(stopButton);
widg->setLayout(hboxLay);
}
QWidget* exclass::retWidg()
{
return widg;
}
QRectF exclass::boundingRect() const
{
}
void exclass:paint(QPainter *painter,const QStyleOptionGraphicsItem *option,QWidget *widget)
{
}
To copy to clipboard, switch view to plain text mode
Bookmarks