0. 基本对话框
dialog.cpp
#include "dialog.h"
#include "ui_dialog.h"
#include <QFileDialog>
#include <QColorDialog>
#include <QFontDialog>
#include <QInputDialog>
Dialog::Dialog(QWidget *parent)
: QDialog(parent)
, ui(new Ui::Dialog)
{
ui->setupUi(this);
}
Dialog::~Dialog()
{
delete ui;
}
void Dialog::on_btnClearText_clicked()
{
ui->plainTextEdit->clear();
}
void Dialog::on_btnOpen_clicked()
{
QString curPath = QDir::currentPath();
QString dlgTitle = "选择对话框";
QString filter = "文本文件(*.txt);;图片文件(*.jpg *.gif);;所有格式(*.*)";
QString filename = QFileDialog::getOpenFileName(this,dlgTitle, curPath,filter);
if(filename.isEmpty()) return;
ui->plainTextEdit->appendPlainText(filename);
}
void Dialog::on_btnOpenMulti_clicked()
{
QString curPath = QDir::currentPath();
QString dlgTitle = "头title";
QString filter = "文本文件(*.txt);;图片文件(*.jpg *.gif);;所有格式(*.*)";
QStringList filenames = QFileDialog::getOpenFileNames(this, dlgTitle,curPath, filter);
if(filenames.count()==0) return;
foreach (QString file, filenames) {
ui->plainTextEdit->appen