Have you done that through designer? Could you please share your application code??? So that we would able to figure out the problem. Use signal slot for the button click, what is this slotTimer???
Added after 5 minutes:
See this code---->
#ifndef NOTEPAD_H
#define NOTEPAD_H
#include <QWidget>
#include<QFile>
#include<QTextStream>
namespace Ui {
class Notepad;
}
{
Q_OBJECT
public:
explicit Notepad
(QWidget *parent
= 0);
~Notepad();
public slots:
void showContent();
private:
Ui::Notepad *ui;
};
#ifndef NOTEPAD_H
#define NOTEPAD_H
#include <QWidget>
#include<QFile>
#include<QTextStream>
namespace Ui {
class Notepad;
}
class Notepad : public QWidget
{
Q_OBJECT
public:
explicit Notepad(QWidget *parent = 0);
~Notepad();
public slots:
void showContent();
private:
Ui::Notepad *ui;
};
To copy to clipboard, switch view to plain text mode
#include "notepad.h"
#include "ui_notepad.h"
Notepad
::Notepad(QWidget *parent
) : ui(new Ui::Notepad)
{
ui->setupUi(this);
connect(ui->pushButton,SIGNAL(clicked()),this,SLOT(showContent()));
}
void Notepad::showContent(){
QFile file("yourfile.txt");
stream>>str;
file.close();
}
ui->textEdit->setText(str);
}
Notepad::~Notepad()
{
delete ui;
}
#include "notepad.h"
#include "ui_notepad.h"
Notepad::Notepad(QWidget *parent) :
QWidget(parent),
ui(new Ui::Notepad)
{
ui->setupUi(this);
connect(ui->pushButton,SIGNAL(clicked()),this,SLOT(showContent()));
}
void Notepad::showContent(){
QString str;
QFile file("yourfile.txt");
if(file.open(QIODevice::ReadOnly)){
QTextStream stream(&file);
stream>>str;
file.close();
}
ui->textEdit->setText(str);
}
Notepad::~Notepad()
{
delete ui;
}
To copy to clipboard, switch view to plain text mode
Bookmarks