Gamalof
13th June 2008, 18:54
i'm making a project, one of its parts in to control the size and place of any shape using sliders.
what i have got till now is, The shape's size is increasing when the slider's value increases,
the Problem is when decreasing the value of the slider, Nothing happen to the shape.
here is wt i did
// MYSlot.h
public:
int GVar;
QGraphicsScene scene;
QGraphicsView * view;
public slots:
void Slider_ValueChanged();
private:
Ui_MyForm ui;
--------------------------------------------
// MySlot.cpp
// The Constructor
MySlot::MySlot(QWidget *parent)
: QWidget(parent)
{
Ui_MyForm d;
MySlot::GVar=1;
//scene = new QGraphicsScene;
view = new QGraphicsView(&(MySlot::scene));
ui.setupUi(this);
}
----------------------------------------
Slider Value Changed Slot.
void MySlot::Slider_ValueChanged()
{
GVar= (int)(ui.horizontalSlider->value());
MySlot::scene.addEllipse (10, 10, GVar, 10,
QPen(Qt::black, 15, Qt::SolidLine, Qt::RoundCap,
Qt::MiterJoin),
QBrush(Qt::blue, Qt::DiagCrossPattern));
MySlot::scene.setBackgroundBrush(Qt::red);
MySlot::view->setAttribute(Qt::WA_DeleteOnClose);
CustomSlot::view ->show();
}
Again, The Problem is .. When the slider's value increases, the shape's size increases, when the slider's value decreases, Nothing happen to the shape.
Thanks :)
what i have got till now is, The shape's size is increasing when the slider's value increases,
the Problem is when decreasing the value of the slider, Nothing happen to the shape.
here is wt i did
// MYSlot.h
public:
int GVar;
QGraphicsScene scene;
QGraphicsView * view;
public slots:
void Slider_ValueChanged();
private:
Ui_MyForm ui;
--------------------------------------------
// MySlot.cpp
// The Constructor
MySlot::MySlot(QWidget *parent)
: QWidget(parent)
{
Ui_MyForm d;
MySlot::GVar=1;
//scene = new QGraphicsScene;
view = new QGraphicsView(&(MySlot::scene));
ui.setupUi(this);
}
----------------------------------------
Slider Value Changed Slot.
void MySlot::Slider_ValueChanged()
{
GVar= (int)(ui.horizontalSlider->value());
MySlot::scene.addEllipse (10, 10, GVar, 10,
QPen(Qt::black, 15, Qt::SolidLine, Qt::RoundCap,
Qt::MiterJoin),
QBrush(Qt::blue, Qt::DiagCrossPattern));
MySlot::scene.setBackgroundBrush(Qt::red);
MySlot::view->setAttribute(Qt::WA_DeleteOnClose);
CustomSlot::view ->show();
}
Again, The Problem is .. When the slider's value increases, the shape's size increases, when the slider's value decreases, Nothing happen to the shape.
Thanks :)