标题:授人以鱼不如授人以渔-圆形刻度盘或者进度条各种计算公式
作者:komany
日期:2017-01-19 10:53
内容:
网上实在找不到计算公式,下面是我动手制作过程中摸索出来的,不准的地方望海涵,有了这公式,刻度盘,进度条随你搞,哈哈哈哈!
遇到事情还是要多动手!!!
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include
#include
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
void paintEvent(QPaintEvent *event);
private:
Ui::MainWindow *ui;
QLabel*l1;
QLabel*l2;
QLabel*l3;
};
#endif // MAINWINDOW_H
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include
//当前值
const int u =43;
//最大刻度
const int nMax = 100;
//最小刻度
const int nMin = 0;
//旋转角度
const double nPercentRotate = 40;
//
const int nMaxRadus = 200;
const int nMinRadus = 150;
const int nDistance = 50;
//最外面的大圆
const int nDistance2 = 70;
//原点
int nOrgXpos = 0;
int nOrgYpos = 0;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
nOrgXpos = width() / 2;
nOrgYpos = height() / 2;
l1 = new QLabel(this);
l1->setText(QString("44"));
l1->move(nOrgXpos ,nOrgYpos );
l2 = new QLabel(this);
l3 = new QLabel(this);
l2->setText(QString("Min"));
//这个地方要注意
l2->move(nOrgXpos - nMinRa ..
#1 [liudianwu 01-19 11:23]
嗯,挺好,挺到位!
#2 [boylebao 01-19 15:41]
#3 [liuqiaoping 04-01 11:05]
平台上第一个可以运行的代码,呜呜呜~