if (qry.exec("SELECT name FROM customer"))
    {
        while(qry.next())
        {
            qDebug() << qry.value(0).toString();
                if(qry.isValid())
                {
                 QString cust 
= qry.
record().
value(0).
toString();
                  lineEdit->setInputMask("0");
                 lineEdit->setMaxLength(1);
                 lineEdit->setGeometry(0,0,41,31);
                 label->setGeometry(0,0,150,41);
 
                 ui->gridLayout->addWidget(label,0,0); //<<<<<<<<<<<Fills the entire width of layout,why?
                 ui->gridLayout->addWidget(lineEdit,0,1);//<<<<<<<<<<<Fills the entire width of layout,why?
                }
        }
    }
    else
    {
        qDebug() << qry.lastError();
    }
        QSqlQuery qry;
    if (qry.exec("SELECT name FROM customer"))
    {
        while(qry.next())
        {
            qDebug() << qry.value(0).toString();
                if(qry.isValid())
                {
                 QString cust = qry.record().value(0).toString();
                 QLabel *label = new QLabel(QString(cust));
                 QLineEdit *lineEdit = new QLineEdit;
                 lineEdit->setInputMask("0");
                 lineEdit->setMaxLength(1);
                 lineEdit->setGeometry(0,0,41,31);
                 label->setGeometry(0,0,150,41);
                 ui->gridLayout->addWidget(label,0,0); //<<<<<<<<<<<Fills the entire width of layout,why?
                 ui->gridLayout->addWidget(lineEdit,0,1);//<<<<<<<<<<<Fills the entire width of layout,why?
                }
        }
    }
    else
    {
        qDebug() << qry.lastError();
    }
To copy to clipboard, switch view to plain text mode 
  
				
Bookmarks