add example where orientation changes dynamically
This commit is contained in:
parent
4410730f22
commit
c15b832857
|
@ -1,5 +1,6 @@
|
|||
#include <QDebug>
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QLineEdit>
|
||||
#include "sliderexamples.h"
|
||||
#include "components/slider.h"
|
||||
|
@ -8,7 +9,8 @@
|
|||
|
||||
SliderExamples::SliderExamples(QWidget *parent)
|
||||
: ExampleList(parent),
|
||||
_edit(new QLineEdit)
|
||||
_edit(new QLineEdit),
|
||||
_slider(new Slider)
|
||||
{
|
||||
QLayout *mainLayout = widget()->layout();
|
||||
|
||||
|
@ -66,10 +68,34 @@ SliderExamples::SliderExamples(QWidget *parent)
|
|||
frame->setWidget(view);
|
||||
|
||||
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(updateValue(int)));
|
||||
// connect(slider, SIGNAL(sliderMoved(int)), this, SLOT(updateValue(int)));
|
||||
|
||||
mainLayout->addWidget(frame);
|
||||
}
|
||||
{
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
QWidget *widget = new QWidget;
|
||||
widget->setLayout(layout);
|
||||
widget->setMinimumWidth(350);
|
||||
|
||||
QPushButton *button = new QPushButton("Change orientation");
|
||||
|
||||
_slider->setMinimumWidth(250);
|
||||
layout->addWidget(_slider);
|
||||
layout->addWidget(button);
|
||||
|
||||
ExampleView *view = new ExampleView;
|
||||
view->setWidget(widget);
|
||||
|
||||
Frame *frame = new Frame;
|
||||
frame->setCodeSnippet(
|
||||
"Slider *slider = new Slider;"
|
||||
);
|
||||
frame->setWidget(view);
|
||||
|
||||
mainLayout->addWidget(frame);
|
||||
|
||||
connect(button, SIGNAL(pressed()), this, SLOT(flip()));
|
||||
}
|
||||
}
|
||||
|
||||
SliderExamples::~SliderExamples()
|
||||
|
@ -80,3 +106,9 @@ void SliderExamples::updateValue(int value)
|
|||
{
|
||||
_edit->setText(QString::number(value));
|
||||
}
|
||||
|
||||
void SliderExamples::flip()
|
||||
{
|
||||
_slider->setOrientation(Qt::Horizontal == _slider->orientation() ?
|
||||
Qt::Vertical : Qt::Horizontal);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "examplelist.h"
|
||||
|
||||
class QLineEdit;
|
||||
class Slider;
|
||||
|
||||
class SliderExamples : public ExampleList
|
||||
{
|
||||
|
@ -15,9 +16,11 @@ public:
|
|||
|
||||
protected slots:
|
||||
void updateValue(int value);
|
||||
void flip();
|
||||
|
||||
private:
|
||||
QLineEdit *const _edit;
|
||||
Slider *const _slider;
|
||||
};
|
||||
|
||||
#endif // SLIDEREXAMPLES_H
|
||||
|
|
Loading…
Reference in New Issue