更新代码

master
feiyangqingyun 2023-06-28 10:19:13 +08:00
parent 6806857a82
commit 8d3216dc12
9 changed files with 65 additions and 3 deletions

View File

@ -1,6 +1,7 @@
#pragma execution_character_set("utf-8") #pragma execution_character_set("utf-8")
#include "widget.h" #include "widget.h"
#include "ui_widget.h" #include "ui_widget.h"
#include "qfiledialog.h"
Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget)
{ {
@ -20,6 +21,18 @@ Widget::~Widget()
delete ui; delete ui;
} }
void Widget::on_btnSelect_clicked()
{
QString fileName = QFileDialog::getOpenFileName();
if (!fileName.isEmpty()) {
ui->cboxUrl->addItem(fileName);
ui->cboxUrl->lineEdit()->setText(fileName);
if (ui->btnOpen->text() == "打开") {
on_btnOpen_clicked();
}
}
}
void Widget::on_btnOpen_clicked() void Widget::on_btnOpen_clicked()
{ {
if (ui->btnOpen->text() == "打开") { if (ui->btnOpen->text() == "打开") {

View File

@ -16,6 +16,7 @@ public:
~Widget(); ~Widget();
private slots: private slots:
void on_btnSelect_clicked();
void on_btnOpen_clicked(); void on_btnOpen_clicked();
private: private:

View File

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>700</width> <width>800</width>
<height>600</height> <height>600</height>
</rect> </rect>
</property> </property>
@ -39,6 +39,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="btnSelect">
<property name="text">
<string>选择</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QPushButton" name="btnOpen"> <widget class="QPushButton" name="btnOpen">
<property name="text"> <property name="text">

View File

@ -1,6 +1,7 @@
#pragma execution_character_set("utf-8") #pragma execution_character_set("utf-8")
#include "widget.h" #include "widget.h"
#include "ui_widget.h" #include "ui_widget.h"
#include "qfiledialog.h"
Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget)
{ {
@ -19,6 +20,18 @@ Widget::~Widget()
delete ui; delete ui;
} }
void Widget::on_btnSelect_clicked()
{
QString fileName = QFileDialog::getOpenFileName();
if (!fileName.isEmpty()) {
ui->cboxUrl->addItem(fileName);
ui->cboxUrl->lineEdit()->setText(fileName);
if (ui->btnOpen->text() == "打开") {
on_btnOpen_clicked();
}
}
}
void Widget::on_btnOpen_clicked() void Widget::on_btnOpen_clicked()
{ {
if (ui->btnOpen->text() == "打开") { if (ui->btnOpen->text() == "打开") {

View File

@ -16,6 +16,7 @@ public:
~Widget(); ~Widget();
private slots: private slots:
void on_btnSelect_clicked();
void on_btnOpen_clicked(); void on_btnOpen_clicked();
private: private:

View File

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>700</width> <width>800</width>
<height>600</height> <height>600</height>
</rect> </rect>
</property> </property>
@ -39,6 +39,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="btnSelect">
<property name="text">
<string>选择</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QPushButton" name="btnOpen"> <widget class="QPushButton" name="btnOpen">
<property name="text"> <property name="text">

View File

@ -19,6 +19,18 @@ Widget::~Widget()
delete ui; delete ui;
} }
void Widget::on_btnSelect_clicked()
{
QString fileName = QFileDialog::getOpenFileName();
if (!fileName.isEmpty()) {
ui->cboxUrl->addItem(fileName);
ui->cboxUrl->lineEdit()->setText(fileName);
if (ui->btnOpen->text() == "打开") {
on_btnOpen_clicked();
}
}
}
void Widget::on_btnOpen_clicked() void Widget::on_btnOpen_clicked()
{ {
if (ui->btnOpen->text() == "打开") { if (ui->btnOpen->text() == "打开") {

View File

@ -16,6 +16,7 @@ public:
~Widget(); ~Widget();
private slots: private slots:
void on_btnSelect_clicked();
void on_btnOpen_clicked(); void on_btnOpen_clicked();
private: private:

View File

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>700</width> <width>800</width>
<height>600</height> <height>600</height>
</rect> </rect>
</property> </property>
@ -39,6 +39,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="btnSelect">
<property name="text">
<string>选择</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QPushButton" name="btnOpen"> <widget class="QPushButton" name="btnOpen">
<property name="text"> <property name="text">