Obtener el tipo de datos de las columnas de una tabla usando QSqlTableModel



  • Como puedo saber el tipo de datos de las columnas de una tabla usando la clase QSqlTableModel


  • Moderators

    Moved to the spanish subforum. Most of us don't speak Spanish but English in the general subforum. You will find Spanish friends there ;)



  • Asi es como pude resolverlo
    @QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName("C:/Documents and Settings/mrondon/Desktop/TestingWithModel/debug/testingdb.db3");

    if(db.open()){
        TableModel *model = new TableModel("clientes");
        model->setQuery("SELECT * FROM " + model->tableName() + " LIMIT 1");
        for(int i = 0; i < model->columnCount(); i++ )
        {
            qDebug() << "Campo:" << model->query().record().field(i).name()
                     << "Tipo Dato:" << model->query().record().field(i).type();
        }
    }@

Log in to reply
 

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