Created
January 10, 2014 00:34
-
-
Save yamato8/8344836 to your computer and use it in GitHub Desktop.
ファイルを全て読み込む:Qt
This file contains hidden or 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 <QFile> | |
#include <QTextStream> | |
#include <QDebug> | |
MainWindow::MainWindow(QWidget *parent) : | |
QMainWindow(parent), | |
ui(new Ui::MainWindow) | |
{ | |
ui->setupUi(this); | |
QFile file("D:\\qt\\FileTest\\data-mini.csv"); | |
if (!file.open(QIODevice::ReadOnly))//読込のみでオープンできたかチェック | |
{ | |
qDebug() << "データ読み込み失敗" ; | |
}else{ | |
QString str; | |
QTextStream in(&file); | |
str = in.readAll();//全文読込 | |
qDebug() << str ; | |
} | |
} | |
MainWindow::~MainWindow() | |
{ | |
delete ui; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment