Time to load a table



  • The more fields have an sqlite database. Or the bigger one of its fields, the longer it will take to load them even if we do not read it?

    for example this table:

    QString consulta;
        consulta.append("CREATE TABLE IF NOT EXISTS semaforos("
                        "interseccion TEXT primary key,"
                        "marca TEXT,"
                        "caracteristica TEXT,"
                        "modelo TEXT,"
                        "red TEXT,"
                        "tiempo TEXT,"
                        "peatonal TEXT,"
                        "tecnologia TEXT,"
                        "cantidad TEXT,"
                        "descripcion TEXT,"
                        "reparacion TEXT,"
                        "instalacion TEXT"
                        ");");
    
    
        QSqlQuery crear(db);
        crear.prepare(consulta);
        crear.exec();
    

    The only term wich increase it's reparacion, but When I show the table in a QTableWidget I do not show that term.

    QString consulta;
        consulta.append("SELECT * FROM semaforos");
        QSqlQuery consultar(db);
    
       consultar.prepare(consulta);
    
    
        consultar.exec();
        int fila=0;
    
    
        ui->tableWidget->setRowCount(0);
    
        while(consultar.next())
        {
            ui->tableWidget->insertRow(fila);
            ui->tableWidget->setItem(fila, 0, new QTableWidgetItem (consultar.value(0).toByteArray().constData()));
    
            ui->tableWidget->setItem(fila, 1, new QTableWidgetItem (consultar.value(1).toByteArray().constData()));
            ui->tableWidget->setItem(fila, 2, new QTableWidgetItem (consultar.value(2).toByteArray().constData()));
            ui->tableWidget->setItem(fila, 3, new QTableWidgetItem (consultar.value(3).toByteArray().constData()));
            ui->tableWidget->setItem(fila, 4, new QTableWidgetItem (consultar.value(4).toByteArray().constData()));
    
            ui->tableWidget->setItem(fila, 5, new QTableWidgetItem (consultar.value(5).toByteArray().constData()));
            ui->tableWidget->setItem(fila, 6, new QTableWidgetItem (consultar.value(6).toByteArray().constData()));
            ui->tableWidget->setItem(fila, 7, new QTableWidgetItem (consultar.value(7).toByteArray().constData()));
            ui->tableWidget->setItem(fila, 8, new QTableWidgetItem (consultar.value(8).toByteArray().constData()));
            ui->tableWidget->setItem(fila, 9, new QTableWidgetItem (consultar.value(9).toByteArray().constData()));
    
            ui->tableWidget->setItem(fila, 10, new QTableWidgetItem (consultar.value(11).toByteArray().constData()));
    
            //ui->tableWidget->setItem(fila, 9, new QTableWidgetItem (consultar.value(9).toByteArray().constData()));
            ui->tableWidget->resizeColumnToContents(0);
            ui->tableWidget->resizeColumnToContents(1);
            ui->tableWidget->resizeColumnToContents(2);
            ui->tableWidget->resizeColumnToContents(3);
            ui->tableWidget->resizeColumnToContents(4);
            ui->tableWidget->resizeColumnToContents(5);
            ui->tableWidget->resizeColumnToContents(6);
            ui->tableWidget->resizeColumnToContents(7);
            ui->tableWidget->resizeColumnToContents(8);
            ui->tableWidget->resizeColumnToContents(9);
    
            ui->tableWidget->resizeColumnToContents(10);
    
    
            fila++;
        }
    

    If the columm reparacion increase so much the showing will be more slower?


  • Lifetime Qt Champion

    Hi,

    Why don't you use a QTableView and QSqlTableModel combo ?



  • thank you are the best. By the way, it's there a method to make more bigger the TableView? because it shows so little when it's call and there is the need to maximize it.


  • Lifetime Qt Champion

    If it looks small then it's likely that you don't have any layout handling it. Add a layout to your "container widget" and then put your QTableView in it.


Log in to reply
 

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