Created
January 28, 2014 19:15
-
-
Save yamato8/8674215 to your computer and use it in GitHub Desktop.
ファイルの読み込み:一行づつ:Qt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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