Skip to content

Instantly share code, notes, and snippets.

@yamato8
Created January 28, 2014 19:15
Show Gist options
  • Save yamato8/8674215 to your computer and use it in GitHub Desktop.
Save yamato8/8674215 to your computer and use it in GitHub Desktop.
ファイルの読み込み:一行づつ:Qt
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
#include <QFile>
#include <QTextCodec>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QFile file("D:\\soft\\pleiades\\xampp\\htdocs\\www\\test.html");
QTextCodec* codec = QTextCodec::codecForName("UTF-8");
if (!file.open(QIODevice::ReadOnly))//読込のみでオープンできたかチェック
{
qDebug() << "データ読み込み失敗" ;
}else{
qDebug() << "データ読み込み成功" ;
}
QTextStream in(&file);
in.setCodec( codec );
while (!in.atEnd()) {
qDebug() << in.readLine();
}
}
MainWindow::~MainWindow()
{
delete ui;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment