Loop in Qt when i call list of tables of database function



  • i'm use an Oracle database in Qt 5.2 with QOCI library. I can open correctly the database and i can view data from a table. Now i want view the list of tables of my DB but when i call the function:

    @QStringList tables=db.tables(QSql::Tables);@

    I dont view ui interface (loop??) and when i stop my app i view this error in exit:

    The program has unexpectedly finished

    Someone has used this function?

    Thanks



  • You should loop through your QStringList:
    @
    QStringList tables=db.tables(QSql::Tables);
    foreach (const QString &str, tables) {
    qDebug() << str;
    }
    @



  • thanks for reply,
    I have same problem... freeze app and after i have error when i exit.. i use QOCI



  • Your QOCI in general is working, as you can open your database and list the content of a table.
    Does your app freeze immediately after initializing the QStringList?
    If not, can you see tables.size()?
    Have you tried to examine the step in Debug mode?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.