本文整理汇总了C++中DatabaseConnection::setUsername方法的典型用法代码示例。如果您正苦于以下问题:C++ DatabaseConnection::setUsername方法的具体用法?C++ DatabaseConnection::setUsername怎么用?C++ DatabaseConnection::setUsername使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabaseConnection
的用法示例。
在下文中一共展示了DatabaseConnection::setUsername方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadConnections
void Project::loadConnections()
{
#ifndef QT_NO_SQL
if ( dbFile.isEmpty() || !QFile::exists( makeAbsolute( dbFile ) ) )
return;
QFile f( makeAbsolute( dbFile ) );
if ( f.open( IO_ReadOnly ) ) {
QDomDocument doc;
QString errMsg;
int errLine;
if ( doc.setContent( &f, &errMsg, &errLine ) ) {
QDomElement e;
e = doc.firstChild().toElement();
/* connections */
QDomNodeList connections = e.toElement().elementsByTagName( "connection" );
for ( uint i = 0; i < connections.length(); i++ ) {
QDomElement connection = connections.item(i).toElement();
QDomElement connectionName = loadSingleProperty( connection, "name" );
QDomElement connectionDriver = loadSingleProperty( connection, "driver" );
QDomElement connectionDatabase = loadSingleProperty( connection,
"database" );
QDomElement connectionUsername = loadSingleProperty( connection,
"username" );
QDomElement connectionHostname = loadSingleProperty( connection,
"hostname" );
QDomElement connectionPort = loadSingleProperty( connection,
"port" );
DatabaseConnection *conn = new DatabaseConnection( this );
conn->setName( connectionName.firstChild().firstChild().toText().data() );
conn->setDriver( connectionDriver.firstChild().firstChild().toText().data() );
conn->setDatabase( connectionDatabase.firstChild().firstChild().toText().data() );
conn->setUsername( connectionUsername.firstChild().firstChild().toText().data() );
conn->setHostname( connectionHostname.firstChild().firstChild().toText().data() );
conn->setPort( QString( connectionPort.firstChild().firstChild().toText().data() ).toInt() );
/* connection tables */
QDomNodeList tables = connection.toElement().elementsByTagName( "table" );
for ( uint j = 0; j < tables.length(); j++ ) {
QDomElement table = tables.item(j).toElement();
QDomElement tableName = loadSingleProperty( table, "name" );
conn->addTable( tableName.firstChild().firstChild().toText().data() );
/* table fields */
QStringList fieldList;
QDomNodeList fields = table.toElement().elementsByTagName( "field" );
for ( uint k = 0; k < fields.length(); k++ ) {
QDomElement field = fields.item(k).toElement();
QDomElement fieldName = loadSingleProperty( field, "name" );
fieldList.append( fieldName.firstChild().firstChild().toText().data() );
}
conn->setFields( tableName.firstChild().firstChild().toText().data(),
fieldList );
}
dbConnections.append( conn );
}
} else {
qDebug( QString("Parse error: ") + errMsg + QString(" in line %d"), errLine );
}
f.close();
}
#endif
}