更新代码

master
feiyangqingyun 2023-06-21 14:32:11 +08:00
parent 8be5fbc548
commit 593a5a1763
6 changed files with 353 additions and 177 deletions

View File

@ -27,7 +27,7 @@ int main(int argc, char *argv[])
#endif #endif
Widget w; Widget w;
w.setWindowTitle("存款计算器 (QQ: 517216493 WX: feiyangqingyun)"); w.setWindowTitle("存款/贷款 计算器 (QQ: 517216493 WX: feiyangqingyun)");
w.show(); w.show();
return a.exec(); return a.exec();

View File

@ -8,6 +8,7 @@
Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget)
{ {
ui->setupUi(this); ui->setupUi(this);
this->initForm();
} }
Widget::~Widget() Widget::~Widget()
@ -15,7 +16,14 @@ Widget::~Widget()
delete ui; delete ui;
} }
void Widget::on_btnOk_clicked() void Widget::initForm()
{
QDateTime now = QDateTime::currentDateTime();
ui->dateStart->setDate(now.date());
ui->dateEnd->setDate(now.date().addYears(1));
}
void Widget::on_btnCalc_clicked()
{ {
//当前多少钱 //当前多少钱
int moneyCurrent = ui->txtMoneyCurrent->text().toInt(); int moneyCurrent = ui->txtMoneyCurrent->text().toInt();
@ -65,3 +73,16 @@ void Widget::on_btnOk_clicked()
ui->txtValue->setText(QString::number(value)); ui->txtValue->setText(QString::number(value));
} }
} }
void Widget::on_btnCalc2_clicked()
{
//计算天数
QDateTime dateStart = ui->dateStart->dateTime();
QDateTime dateEnd = ui->dateEnd->dateTime();
int day = dateStart.daysTo(dateEnd);
int money = ui->txtMoney2->text().toInt();
float rate = ui->txtRate2->text().toFloat();
int result = money * rate * day;
ui->txtResult2->setText(QString::number(result));
qDebug() << day;
}

View File

@ -15,11 +15,13 @@ public:
explicit Widget(QWidget *parent = 0); explicit Widget(QWidget *parent = 0);
~Widget(); ~Widget();
private slots:
void on_btnOk_clicked();
private: private:
Ui::Widget *ui; Ui::Widget *ui;
private slots:
void initForm();
void on_btnCalc_clicked();
void on_btnCalc2_clicked();
}; };
#endif // WIDGET_H #endif // WIDGET_H

View File

@ -13,6 +13,12 @@
<property name="windowTitle"> <property name="windowTitle">
<string>存款计算器</string> <string>存款计算器</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>存款计算</string>
</property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QWidget" name="widget" native="true"> <widget class="QWidget" name="widget" native="true">
@ -80,7 +86,7 @@
</widget> </widget>
</item> </item>
<item row="0" column="4" rowspan="3"> <item row="0" column="4" rowspan="3">
<widget class="QPushButton" name="btnOk"> <widget class="QPushButton" name="btnCalc">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding"> <sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -192,6 +198,9 @@
</layout> </layout>
</widget> </widget>
</item> </item>
</layout>
</widget>
</item>
<item row="0" column="1"> <item row="0" column="1">
<spacer name="horizontalSpacer"> <spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">
@ -206,6 +215,140 @@
</spacer> </spacer>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="minimumSize">
<size>
<width>0</width>
<height>200</height>
</size>
</property>
<property name="title">
<string>贷款计算</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="1" column="2">
<widget class="QLabel" name="labRate2">
<property name="text">
<string>贷款利率</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="labMoney2">
<property name="text">
<string>贷款金额</string>
</property>
</widget>
</item>
<item row="0" column="6" rowspan="2">
<widget class="QPushButton" name="btnCalc2">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>计算</string>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QLineEdit" name="txtRate3">
<property name="text">
<string>0.0003</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labEnd">
<property name="text">
<string>到期日期</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="labRate3">
<property name="text">
<string>逾期利率</string>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QLineEdit" name="txtRate4">
<property name="text">
<string>0.0003</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDateEdit" name="dateStart">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="displayFormat">
<string>yyyy-MM-dd</string>
</property>
<property name="calendarPopup">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDateEdit" name="dateEnd">
<property name="displayFormat">
<string>yyyy-MM-dd</string>
</property>
<property name="calendarPopup">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLineEdit" name="txtMoney2">
<property name="text">
<string>100000</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="txtRate2">
<property name="text">
<string>0.0003</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="labStart">
<property name="text">
<string>贷款日期</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QLabel" name="labRate4">
<property name="text">
<string>复利利率</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labValue2">
<property name="text">
<string>贷款利息</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="txtResult2"/>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -228,7 +371,7 @@
<tabstop>txtYears</tabstop> <tabstop>txtYears</tabstop>
<tabstop>cboxType</tabstop> <tabstop>cboxType</tabstop>
<tabstop>txtMoneyAll</tabstop> <tabstop>txtMoneyAll</tabstop>
<tabstop>btnOk</tabstop> <tabstop>btnCalc</tabstop>
<tabstop>rbtn1</tabstop> <tabstop>rbtn1</tabstop>
<tabstop>txtValue1</tabstop> <tabstop>txtValue1</tabstop>
<tabstop>rbtn2</tabstop> <tabstop>rbtn2</tabstop>

View File

@ -231,6 +231,7 @@ bool FFmpegThread::init()
void FFmpegThread::run() void FFmpegThread::run()
{ {
qint64 startTime = av_gettime();
while (!stopped) { while (!stopped) {
//根据标志位执行初始化操作 //根据标志位执行初始化操作
if (isPlay) { if (isPlay) {
@ -270,16 +271,25 @@ void FFmpegThread::run()
emit receiveImage(image); emit receiveImage(image);
} }
msleep(1); usleep(1);
} }
#if 1
//延时(不然文件会立即全部播放完)
AVRational timeBase = {1, AV_TIME_BASE};
int64_t ptsTime = av_rescale_q(avPacket->dts, avFormatContext->streams[videoStreamIndex]->time_base, timeBase);
int64_t nowTime = av_gettime() - startTime;
if (ptsTime > nowTime) {
av_usleep(ptsTime - nowTime);
}
#endif
} else if (index == audioStreamIndex) { } else if (index == audioStreamIndex) {
//解码音频流,这里暂不处理,以后交给sdl播放 //解码音频流,自行处理
} }
} }
av_packet_unref(avPacket); av_packet_unref(avPacket);
av_freep(avPacket); av_freep(avPacket);
msleep(1); usleep(1);
} }
//线程结束后释放资源 //线程结束后释放资源

View File

@ -9,7 +9,7 @@ Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget)
//本示例支持的是rtsp视频流(其他的一概不支持/没有做音视频同步) //本示例支持的是rtsp视频流(其他的一概不支持/没有做音视频同步)
QStringList urls; QStringList urls;
urls << "http://vfx.mtime.cn/Video/2021/11/16/mp4/211116131456748178.mp4"; urls << "http://vfx.mtime.cn/Video/2021/11/16/mp4/211116131456748178.mp4";
urls << "rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov"; urls << "http://vd3.bdstatic.com/mda-jennyc5ci1ugrxzi/mda-jennyc5ci1ugrxzi.mp4";
urls << "rtsp://admin:Admin123456@192.168.0.15:554/media/video1"; urls << "rtsp://admin:Admin123456@192.168.0.15:554/media/video1";
ui->cboxUrl->addItems(urls); ui->cboxUrl->addItems(urls);
ui->cboxUrl->setCurrentIndex(0); ui->cboxUrl->setCurrentIndex(0);