本文整理汇总了C++中QTextStream::readAll方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextStream::readAll方法的具体用法?C++ QTextStream::readAll怎么用?C++ QTextStream::readAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextStream
的用法示例。
在下文中一共展示了QTextStream::readAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getAllStoragePoolDataList
Result StoragePoolControlThread::getAllStoragePoolDataList()
{
Result result;
QStringList storagePoolDataList;
if ( task.srcConnPtr!=NULL && keep_alive ) {
virStoragePoolPtr *storagePool = NULL;
unsigned int flags = VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE |
VIR_CONNECT_LIST_STORAGE_POOLS_INACTIVE;
int ret = virConnectListAllStoragePools(
*task.srcConnPtr, &storagePool, flags);
if ( ret<0 ) {
result.err = sendConnErrors();
result.result = false;
result.msg = storagePoolDataList;
return result;
};
// therefore correctly to use for() command, because storagePool[0] can not exist.
for (int i = 0; i < ret; i++) {
QStringList currentAttr;
QString type, source, target;
char *Returns = (virStoragePoolGetXMLDesc(storagePool[i], VIR_STORAGE_XML_INACTIVE));
if ( Returns!=NULL ) {
QDomDocument doc;
QString s;
QTextStream str;
str.setString(&s);
doc.setContent(QString(Returns));
QDomElement _pool, _el;
_pool= doc.firstChildElement("pool");
type = _pool.attribute("type");
_el = _pool.firstChildElement("source");
_el.save(str, 4);
source = str.readAll();
_el = _pool.firstChildElement("target");
_el.save(str, 4);
target = str.readAll();
free(Returns);
};
currentAttr<< QString::fromUtf8( virStoragePoolGetName(storagePool[i]) )
<< type << source << target;
storagePoolDataList.append(currentAttr.join(DFR));
//qDebug()<<currentAttr;
virStoragePoolFree(storagePool[i]);
};
free(storagePool);
result.result = true;
} else {
result.result = false;
};
result.msg = storagePoolDataList;
return result;
}
示例2: aboutInit
void About::aboutInit()
{
setModal(true);
resize(400, 400);
setWindowTitle("About");
setWindowIcon(QIcon("icons/backupsoft.png"));
QWidget *icon = new QWidget(this);
icon->setStyleSheet("background-image: url(icons/backupsoft.png)");
icon->setGeometry(250 , 10, 100, 100);
QLabel *title = new QLabel("BackupSoft", this);
title->setFont(QFont("Helvetica", 25, 10, false));
title->setGeometry(10, 10, 200, 30);
QLabel *version = new QLabel("Copyright 2010 by\nMichael Kohler and Fabian Gammenthaler\n\nVersion: 1.0", this);
version->setFont(QFont("Helvetica", 8, 2, false));
version->setGeometry(10, 70, 200, 55);
QTextEdit *licence = new QTextEdit(this);
licence->setGeometry(10, 160, 380, 230);
licence->setReadOnly(true);
QFile *file = new QFile("licence.txt");
if (file->open(QIODevice::ReadOnly)) {
QTextStream *stream = new QTextStream(file);
licence->setText(stream->readAll());
}
else {
QString errorMsg = "Could not open licence.txt.. Please make sure it is existent and readable.";
AlertWindow *alertWin = new AlertWindow("ERROR", "", errorMsg);
alertWin->show();
}
}
示例3: loadTPL
bool loadTPL(Translator &translator, QIODevice &dev, ConversionData &cd)
{
// Hack: Check if the template is utf8
QTextStream testStream;
testStream.setDevice( &dev );
QString testContent = testStream.readAll();
if ( ( testContent.startsWith( QLatin1String("{*?template charset="), Qt::CaseInsensitive ) &&
( testContent.startsWith( QLatin1String("{*?template charset=utf8?*}"), Qt::CaseInsensitive ) ||
testContent.startsWith( QLatin1String("{*?template charset=utf-8?*}"), Qt::CaseInsensitive ) ) ) ||
cd.m_assumeUtf8 )
{
stream.setCodec( QTextCodec::codecForName("UTF-8") );
stream.setAutoDetectUnicode( true );
}
else
{
stream.setCodec( QTextCodec::codecForLocale() );
stream.setAutoDetectUnicode( false );
}
stream.setDevice( &dev );
stream.seek( 0 ); // we need to rewind it because the testStream has read all data on the QIODevice
parse( &translator, cd.m_sourceDir.path() + QDir::separator() + cd.m_sourceFileName );
return true;
}
示例4: notesDocument
QTextDocument* KateProject::notesDocument ()
{
/**
* already there?
*/
if (m_notesDocument)
return m_notesDocument;
/**
* else create it
*/
m_notesDocument = new QTextDocument (this);
m_notesDocument->setDocumentLayout (new QPlainTextDocumentLayout (m_notesDocument));
/**
* and load text if possible
*/
if (QFile *inFile = projectLocalFile ("notes.txt")) {
{
QTextStream inStream (inFile);
inStream.setCodec ("UTF-8");
m_notesDocument->setPlainText (inStream.readAll ());
}
delete inFile;
}
/**
* and be done
*/
return m_notesDocument;
}
示例5: openFile
bool TextManager::openFile(const QString &filePath, const QString &generatorName, const text::LanguageInfo &language)
{
QFile file(filePath);
QTextStream *inStream = nullptr;
if (!file.isOpen() && file.open(QIODevice::ReadOnly | QIODevice::Text)) {
inStream = new QTextStream(&file);
inStream->setCodec(QTextCodec::codecForName("UTF-8"));
QScintillaTextEdit *area = new QScintillaTextEdit();
area->setCurrentLanguage(language);
area->setText(inStream->readAll());
mText.insert(filePath, area);
mPath.insert(area, filePath);
mPathType.insert(filePath, true);
mModified.insert(filePath, QPair<bool, bool>(false, false));
mGeneratorName.insert(filePath, generatorName);
mCodeBlockManager.addNewCode(filePath);
connect(area, SIGNAL(textWasModified(text::QScintillaTextEdit*))
, this, SLOT(setModified(text::QScintillaTextEdit*)));
return true;
}
示例6: loadJS
QScriptValue loadJS(QScriptContext *context, QScriptEngine *engine)
{
QString result;
for ( int i = 0; i < context->argumentCount(); ++i ) {
if ( i > 0 ) {
result.append(" ");
}
result.append(context->argument(i).toString());
}
QFile scriptFile(result);
// check file is exited or not
if ( !scriptFile.open(QIODevice::ReadOnly) ) {
return QScriptValue();
}
// load file
QTextStream stream (&scriptFile);
QString s = stream.readAll();
scriptFile.close();
// set ScriptContext
QScriptContext *parent = context->parentContext();
if( parent != 0 ) {
context->setActivationObject(context->parentContext()->activationObject());
context->setThisObject(context->parentContext()->thisObject());
}
// execute script
return engine->evaluate(s, result);
}
示例7: build_prelude
help::prelude_t help::build_prelude () {
help::prelude_t ret;
QStringList args = QCoreApplication::arguments ();
QString ver ("X2Go Client " + QString (VERSION));
if (QFile::exists (":/txt/git-info")) {
QFile file (":/txt/git-info");
if (file.open (QIODevice::ReadOnly | QIODevice::Text)) {
QTextStream stream (&file);
QString git_info (stream.readAll ().trimmed ());
git_info = git_changelog_extract_commit_sha (git_info);
if (!(git_info.isEmpty ())) {
ver.append (" (Git information: " + git_info + ")");
}
}
}
ret.append (ver);
ret.append ("Usage: " + QString (args.at (0)) + " [OPTION]...");
ret.append ("Options:");
ret.append ("");
return (ret);
}
示例8: aboutLicense
void MainWindow::aboutLicense() {
QDialog *dialog = new QDialog( this );
QFile file( ":/GPL" );
if(!file.open( QIODevice::ReadOnly | QIODevice::Text ))
qCritical( "GPL LicenseFile not found" );
QTextStream out ( &file );
out.setFieldAlignment ( QTextStream::AlignCenter );
QTextEdit *qteLicense = new QTextEdit ( dialog );
qteLicense->setText ( out.readAll ());
qteLicense->setReadOnly ( 1 );
QPushButton *qpbClose = new QPushButton ( IconLoader::Load( "window-close" ), tr( "&Close" ), dialog );
connect( qpbClose, SIGNAL( clicked()), dialog, SLOT( deleteLater()));
qglDialog = new QGridLayout( dialog );
qglDialog->addWidget( qteLicense, 0, 0 );
qglDialog->addWidget( qpbClose, 1, 0, Qt::AlignRight );
dialog->setLayout( qglDialog);
dialog->setWindowTitle( "GNU General Public License" );
dialog->setFixedSize( 550, 400 );
dialog->exec();
}
示例9: odczyt_z_pliku
QString Plik::odczyt_z_pliku()
{
qDebug() << "[Plik::odczyt_z_pliku()]";
QFile plik(sciezka);
tekst="";
if(!plik.open(QIODevice::ReadOnly | QIODevice::Text))
{
qDebug() << "Nie można było otworzyc pliku do odczytu\n";
// QMessageBox::warning(
// this,
// QObject::tr("Hello World"),
// "Wystąpił błąd w dostępie do pliku"
// );
return tekst;
}
QTextStream in (&plik);
tekst = in.readAll();
qDebug() << "Wczytano Następujące Dane z Pliku:\n";
qDebug() << tekst << "\n";
plik.flush();
plik.close();
return tekst;
}
示例10: content
void
WarrantyWidget::initialize ()
{
QSettings content (configFile, QSettings::IniFormat);
m_warrantyTimer =
content.value ("warrantytimer", true).toBool ();
m_warrantyText =
content.value ("warrantytext", "qtn_warr_terms").toString ();
SYS_DEBUG ("show warranty timer = %s", SYS_BOOL (m_warrantyTimer));
SYS_DEBUG ("warranty_text = %s", SYS_STR (m_warrantyText));
if (! m_warrantyText.isEmpty ())
{
if (m_warrantyText.contains ("qtn_"))
m_warrantyText = qtTrId (m_warrantyText.toAscii ().constData ());
else
{
QFile warrantyFile (configPath + m_warrantyText);
if (warrantyFile.open (QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream inStream (&warrantyFile);
m_warrantyText = inStream.readAll ();
}
else
{
SYS_WARNING ("Warranty text cannot be loaded!");
m_warrantyText = "";
}
}
}
}
示例11: readFileIntoContendor
int TableContendor::readFileIntoContendor (QString ifilename)
{
bool res;
QFile infile(ifilename);
if (!infile.open(QIODevice::ReadOnly | QIODevice::Text))
{
qDebug()<<"Error while opening file";
return 1;
}
QTextStream str (&infile);
QStringList listOfLines = str.readAll().split("\n");
QStringList namesLst = listOfLines.at(0).trimmed().split("\t");
int gnumberOfColumns = namesLst.count();
int gnumberOfRows = listOfLines.count();
setSizes(gnumberOfColumns,gnumberOfRows-1);
int i=0;
foreach (QString name, namesLst)
{
setColumnName(i, name);
i++;
}
示例12: processInput
void processInput(QTextStream& in, QList<Streamable>* streamables) {
Class clazz;
Streamable currentStreamable;
QRegExp exp(
"(/\\*.*\\*/)|" // multi-line comments
"(//.*\n)|" // single-line comments
"(\\s*#.*\n)|" // preprocessor definitions
"(\\s*STREAMABLE\\s+)|" // STREAMABLE tag for classes
"(\\s*STREAM\\s+.*;)|" // STREAM tag for fields
"(\\s*class\\s+[^;]+\\{)" // class definition
);
exp.setMinimal(true);
QRegExp classExp("class (\\w+) ?:?([^:]*)\\{");
// read in the entire input and look for matches with our expression
QString all = in.readAll();
for (int off = 0; (off = exp.indexIn(all, off)) != -1; off += exp.matchedLength()) {
QString match = exp.cap().simplified();
if (match.startsWith("/*") || match.startsWith("//") || match.startsWith('#')) {
continue; // comment, preprocessor definition
}
if (match.startsWith("STREAMABLE")) {
if (clazz.name.isEmpty()) {
cerr << "Found STREAMABLE marker before class definition." << endl;
continue;
}
if (!currentStreamable.clazz.name.isEmpty()) {
streamables->append(currentStreamable);
}
currentStreamable.clazz = clazz;
currentStreamable.fields.clear();
} else if (match.startsWith("STREAM")) {
match.chop(1); // get rid of the semicolon
match = match.mid(match.indexOf(' ') + 1).trimmed(); // and STREAM, and any space before it
int index = match.lastIndexOf(' ');
Field field = { match.left(index).simplified(), match.mid(index + 1) };
currentStreamable.fields.append(field);
} else { // match.startsWith("class")
classExp.exactMatch(match);
clazz.name = classExp.cap(1);
clazz.bases.clear();
foreach (const QString& bstr, classExp.cap(2).split(',')) {
QString base = bstr.trimmed();
if (!base.isEmpty() && base.startsWith("STREAM")) {
clazz.bases.append(base.mid(base.lastIndexOf(' ') + 1));
}
}
}
}
if (!currentStreamable.clazz.name.isEmpty()) {
streamables->append(currentStreamable);
}
}
示例13: nodeCreated
void DebugView::nodeCreated(const ModelNode &createdNode)
{
if (isDebugViewEnabled()) {
QTextStream message;
QString string;
message.setString(&string);
message << createdNode;
log(tr("Node created:"), message.readAll());
}
}
示例14: loadFile
void IWindow::loadFile(QString &file)
{
FILE *fh = fopen(file.toAscii().data(), "r");
if (fh == 0)
return;
QTextStream *ts = new QTextStream(fh, QIODevice::ReadOnly);
m_input->document()->setPlainText(ts->readAll());
delete ts;
fclose(fh);
}
示例15: click
void TicketQToolButton::click()
{
BL_FUNC_DEBUG
QString txt = "";
/// Copiamos el archivo.
QString archivo = g_confpr->value( CONF_DIR_OPENREPORTS ) + "etiquetas.rml";
QString archivod = g_confpr->value( CONF_DIR_USER ) + "etiquetas.rml";
blCopyFile(archivo,archivod);
BlFile file;
file.setFileName ( archivod );
file.open ( QIODevice::ReadOnly );
QTextStream stream ( &file );
QString buff = stream.readAll();
file.close();
QString fitxersortidatxt = "";
/// Hacemos el texto de las etiquetas.
m_companyact = m_albaranProveedorView->mainCompany();
QString query = "SELECT * , ceil(cantlalbaranp) AS cantidad FROM lalbaranp NATURAL LEFT JOIN articulo WHERE idalbaranp = " + m_albaranProveedorView->dbValue ( "idalbaranp" );
BlDbRecordSet *cur = m_companyact->loadQuery ( query );
while ( !cur->eof() ) {
int i = 0;
while ( i < cur->value( "cantidad" ).toInt() ) {
fitxersortidatxt += "<blockTable><tr><td>";
fitxersortidatxt += "<para><font face=\"Helvetica\" size=\"4\">" + cur->value( "nomarticulo" ) + "</font></para>\n";
fitxersortidatxt += "<barCode code=\"code128\" height=\"0.60cm\">" + cur->value( "codigocompletoarticulo" ) + "</barCode>\n";
fitxersortidatxt += "<para><font face=\"Helvetica\" size=\"4\">" + cur->value( "codigocompletoarticulo" ) + " - (" + m_albaranProveedorView->dbValue ( "fechaalbaranp" ).left ( 10 ) + ")</font></para>\n";
// if (cur->numcampo("lotelalbaranp") != -1)
// fitxersortidatxt += "<para><font face=\"Helvetica\" size=\"4\"> Lote: " + cur->value("lotelalbaranp") + "</font></para>\n";
fitxersortidatxt += "</td></tr></blockTable>";
fitxersortidatxt += "<spacer length=\"0.5cm\"/>\n";
i++;
} // end while
cur->nextRecord();
} // end while
delete cur;
buff.replace ( "[story]", fitxersortidatxt );
if ( file.open ( QIODevice::WriteOnly ) ) {
QTextStream stream ( &file );
stream << buff;
file.close();
} // end if
blCreateAndLoadPDF ( "etiquetas" );
}