Skip to content

Instantly share code, notes, and snippets.

@yamato8
Created January 10, 2014 00:34
Show Gist options
  • Save yamato8/8344836 to your computer and use it in GitHub Desktop.
Save yamato8/8344836 to your computer and use it in GitHub Desktop.
ファイルを全て読み込む:Qt
#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