計劃基本上我做了一個簡單的程序來閱讀文本行,但每當我運行該程序,我得到的簡單的Qt閱讀從文本文件未編譯
no match for 'operator>>' (operand types are 'QFile' and 'QString')
while(file >> name >> month >> day >> year >> subject >> level >> apages >> total >> one >> two >> three >> four >> five >> six >> seven >> eight >> nine >> ten)
錯誤和其他錯誤:
expected unqualified-id before '<<' token
QDebug << QString(name);
我一直在試圖找到一個小時在線的東西,但我真的找不到任何有用或我能理解的東西。我真的很感激任何可以提供的輸入。
相關代碼:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtCore/QCoreApplication>
#include <QtCore>
#include <QFile>
#
#include <QDebug>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
QString name, month, subject, level;
int day, year, apages, total, one, two, three, four, five, six, seven, eight, nine, ten;
QFile file("C:/Users/brandan/Desktop/GUIPrograms/Kumon.txt");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return;
while(file >> name >> month >> day >> year >> subject >> level >> apages >> total >> one >> two >> three >> four >> five >> six >> seven >> eight >> nine >> ten)
{
QDebug << name << month << day << year << subject << level << apages << total << one << two << three << four << five << six << seven << eight << nine << ten;
}
}
好的,你能否給我舉個例子 – user3183403
@ user3183403:提示#1:藍色文字是超鏈接,點擊它們會在你的網頁瀏覽器中打開一個新頁面。提示#2:QT的人員幫助將樣本包含在他們的在線幫助中。 – usr2564301