Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Time to load a table
QtWS25 Last Chance

Time to load a table

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 926 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • JulianJ Offline
    JulianJ Offline
    Julian
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • JulianJ Offline
        JulianJ Offline
        Julian
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          2

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved