pt.h
#ifndef PT_H
#define PT_H
#include <QWidget>
//#include<QPushButton>
//#include "pt.h"
namespace Ui {
class pt;
}
Q_OBJECT
public:
~pt();
public slots:
void browse();
protected:
private:
Ui::pt *ui;
};
#endif // PT_H
#ifndef PT_H
#define PT_H
#include <QWidget>
//#include<QPushButton>
//#include "pt.h"
namespace Ui {
class pt;
}
class pt : public QWidget {
Q_OBJECT
public:
pt(QWidget *parent = 0);
~pt();
public slots:
void browse();
protected:
void changeEvent(QEvent *e);
private:
Ui::pt *ui;
};
#endif // PT_H
To copy to clipboard, switch view to plain text mode
[/CODE]
main.cpp
#include <QtGui/QApplication>
//#include<QtGui/QPushButton>
//#include<QFileDialog>
#include "pt.h"
int main(int argc, char *argv[])
{
pt w;
w.show();
return a.exec();
}
#include <QtGui/QApplication>
//#include<QtGui/QPushButton>
//#include<QFileDialog>
#include "pt.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
pt w;
w.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
pt.cpp
//#include<QtGui/QApplication>
#include<QFileDialog>
//#include<QtGui>
//#include<QtGui/QPushButton>
#include "pt.h"
#include "ui_pt.h"
ui(new Ui::pt)
{
ui->setupUi(this);
// connect( pushButton, SIGNAL( clicked() ), this, SLOT( browse() ) );
connect( ui->pushButton, SIGNAL( clicked() ), this, SLOT( browse() ) );
}
pt::~pt()
{
delete ui;
}
void pt::browse()
{
this,
"Choose a file to open",
ui->lineEdit->setText( path );
}
void pt
::changeEvent(QEvent *e
) {
switch (e->type()) {
ui->retranslateUi(this);
break;
default:
break;
}
}
//#include<QtGui/QApplication>
#include<QFileDialog>
//#include<QtGui>
//#include<QtGui/QPushButton>
#include "pt.h"
#include "ui_pt.h"
pt::pt(QWidget *parent) :
QWidget(parent),
ui(new Ui::pt)
{
ui->setupUi(this);
// connect( pushButton, SIGNAL( clicked() ), this, SLOT( browse() ) );
connect( ui->pushButton, SIGNAL( clicked() ), this, SLOT( browse() ) );
}
pt::~pt()
{
delete ui;
}
void pt::browse()
{
QString path;
path = QFileDialog::getOpenFileName(
this,
"Choose a file to open",
QString::null,
QString::null);
ui->lineEdit->setText( path );
}
void pt::changeEvent(QEvent *e)
{
QWidget::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
To copy to clipboard, switch view to plain text mode
Does this work?
Bookmarks