QT27 how to read text file and display file to a textbrowser or textedit

#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <QFile>
#include <QTextStream>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QFile file("C:/AdwCleaner/AdwCleaner[S1].txt");
    if(!file.open(QIODevice::ReadOnly))
        qDebug() << "open error";
    QTextStream in(&file);
    ui->textBrowser->setText(in.readAll());
}



MainWindow::~MainWindow()
{
    delete ui;
}

QT27 how to read text file and display file to a textbrowser or textedit_第1张图片

你可能感兴趣的:(QT27 how to read text file and display file to a textbrowser or textedit)