#include <QApplication>
#include <QWidget>
#include <QPushButton>
#include <QLCDNumber>
#include <QSlider>
#include <QVBoxLayout>
#include <iostream>
{
public:
~MyWidget() { std::cout << "abc" << std::endl; }
private:
private slots:
void SetSliderValue() { slider->setValue(0); }
};
{
setFixedSize(320, 200);
slider->setValue(0);
slider->setRange(0, 99);
connect(resetButton, SIGNAL(clicked() ), this, SLOT(SetSliderValue() ) );
connect(slider, SIGNAL(valueChanged(int) ), lcd, SLOT(display(int) ) );
layout->addWidget(resetButton);
layout->addWidget(lcd);
layout->addWidget(slider);
setLayout(layout);
}
int main(int argc, char *argv[] )
{
MyWidget widget;
widget.show();
app.exec();
}
#include <QApplication>
#include <QWidget>
#include <QPushButton>
#include <QLCDNumber>
#include <QSlider>
#include <QVBoxLayout>
#include <iostream>
class MyWidget : public QWidget
{
public:
MyWidget(QWidget *parent);
~MyWidget() { std::cout << "abc" << std::endl; }
private:
QSlider *slider;
private slots:
void SetSliderValue() { slider->setValue(0); }
};
MyWidget::MyWidget(QWidget *parent = 0) : QWidget(parent)
{
setFixedSize(320, 200);
QPushButton *resetButton = new QPushButton("Reset");
QLCDNumber *lcd = new QLCDNumber(2);
lcd->setSegmentStyle(QLCDNumber::Filled);
QSlider *slider = new QSlider(Qt::Horizontal);
slider->setValue(0);
slider->setRange(0, 99);
connect(resetButton, SIGNAL(clicked() ), this, SLOT(SetSliderValue() ) );
connect(slider, SIGNAL(valueChanged(int) ), lcd, SLOT(display(int) ) );
QVBoxLayout *layout = new QVBoxLayout();
layout->addWidget(resetButton);
layout->addWidget(lcd);
layout->addWidget(slider);
setLayout(layout);
}
int main(int argc, char *argv[] )
{
QApplication app(argc, argv);
MyWidget widget;
widget.show();
app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks