QT5-控件-QDial(表盘控件)


#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QDial>

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();

    QDial* dl[10];

public slots:
    void changedDate();
};

#endif // MAINWINDOW_H
#include "mainwindow.h"
#include <QtDebug>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    this->resize(400,400);
    this->centralWidget();

    int xpos = 30 ;
    for(int i=0;i<3;i++)
    {
        dl[i] = new QDial(this);
        dl[i]->setRange(0,100);
        dl[i]->setGeometry(xpos,30,100,100);
        xpos += 110;
    }
    // 显示刻度
    dl[0]->setNotchesVisible(true);
    connect(dl[0],SIGNAL(valueChanged(int)),this,SLOT(changedDate()));
}

MainWindow::~MainWindow()
{

}

void MainWindow::changedDate()
{
    qDebug()<<dl[0]->value();
}
#include "mainwindow.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    return a.exec();
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM