马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 ~风介~ 于 2015-11-20 20:02 编辑
Code://widget.h
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
QT_BEGIN_NAMESPACE
class QDial;
class QSpinBox;
QT_END_NAMESPACE
class Widget : public QWidget
{
Q_OBJECT
public:
Widget();
private:
QDial *dial;
QSpinBox *spinBox;
};
#endif // WIDGET_H
+++//widget.cpp
#include "widget.h"
#include <QtWidgets>
Widget::Widget()
{
dial = new QDial;
spinBox = new QSpinBox;
dial->setMaximum(60);
dial->setMinimum(0);
dial->setValue(1);
//dial->setNotchTarget(1.0);
//dial->setSingleStep(1);
//dial->notchTarget();
//dial->notchesVisible();
//dial->setWrapping(true);
spinBox->setMaximum(60);
spinBox->setMinimum(0);
spinBox->setValue(1);
connect(dial,SIGNAL(valueChanged(int)),spinBox,SLOT(setValue(int)));
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(dial);
mainLayout->addWidget(spinBox);
this->setLayout(mainLayout);
this->resize(300,300);
}
+++//main.cpp
#include "widget.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
w.show();
return a.exec();
}
Screenshot:
|