//dialog.h#ifndef DIALOG_H#define DIALOG_H#include <QDialog>#include <QLineEdit>#include <QGridLayout>class Dialog : public QDialog{ Q_OBJECTpublic: Dialog(QWidget *parent = 0); ~Dialog();private: QPushButton *fileBtn; QLineEdit *fileLineEdit; QGridLayout *mainLayout;private slots: void showFile();};#endif // DIALOG_H
//dialog.cpp#include "dialog.h"#include <QGridLayout>#include <QFileDialog>#include <QPushButton>Dialog::Dialog(QWidget *parent) : QDialog(parent){ setWindowTitle(tr("Every Standard Dialog Instance")); fileBtn=new QPushButton; fileBtn->setText(tr("File Standard Dialog Instance")); fileLineEdit=new QLineEdit; mainLayout=new QGridLayout(this); mainLayout->addWidget(fileBtn,0,0); mainLayout->addWidget(fileLineEdit,0,1); connect(fileBtn,SIGNAL(clicked()),this,SLOT(showFile()));}void Dialog::showFile(){ QString s=QFileDialog::getOpenFileName(this,"open file dialog","/",tr("Program Files (*.cpp *.c *.h)")); fileLineEdit->setText(s);}Dialog::~Dialog(){}
:
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/200P643M-0.jpg "style =" float: none; "title =" 1.jpg" alt = "162617504.jpg"/>
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/200PA409-1.jpg "style =" float: none; "title =" 2.jpg" alt = "162617218.jpg"/>
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/200P61259-2.jpg "style =" float: none; "title =" 3.jpg" alt = "162618319.jpg"/>
This article is from the "cabbage" blog, please be sure to keep this source http://zhengyongkun.blog.51cto.com/1163218/1296498