新建一个QT工程
然后在cpp文件中写入代码
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include "hello.h" #include <qthread.h> #include <QVariant> #include <qstring.h> Hello::Hello(QWidget *parent) : QDialog(parent) { ui.setupUi(this); ui.slider->setRange(0,1000); connect(ui.slider,SIGNAL(valueChanged(int)),ui.lcd,SLOT(display(int))); } Hello::~Hello() { }
拉动滑块就可以改变lcdnumber中的数值。