#include "dialog.h" #include "ui_dialog.h" #include <qmath.h> Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog) { ui->setupUi(this); ui->lablePic->setScaledContents(true); QPixmap pix(":/pic/pic.png"); ui->lablePic->setPixmap(pix); ui->lablePic->resize(pix.size()); setMaximumSize(size()); setMinimumSize(size()); setWindowTitle("电机死区常数τ=RC计算 by:郭树人 QQ:1085081059"); } Dialog::~Dialog() { delete ui; } void Dialog::on_btnRC_clicked() { double V1 = ui->lnV1->text().toDouble(); double V2 = ui->lnV2->text().toDouble(); double V3 = ui->lnV3->text().toDouble(); double t = ui->lnT->text().toDouble(); double rc = ui->lnRC->text().toDouble(); //初始电容电压 V1 //死区阈值电压 V2 //电源电压 V3 //V2 = V1 + (V3 – V1) * [1 – exp( -t/RC)] double temp = 0 ; temp = (V2 - V1)/(V3 - V1); temp = 1- temp ; rc = (-t)/qLn(temp); ui->lnRC->setText(QString::number(rc)); }
http://pan.baidu.com/s/1jIxadka
原文:http://www.cnblogs.com/JJLQ/p/7113559.html