PDA

View Full Version : Compiling error with list.count



xleniz
9th June 2012, 13:27
Hi, Ive started to make a database edit program, and I have an error

Here's code:


#include <QtGui/QApplication>
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlQuery>
#include <QWidget>
#include "widget.h"
#include <QtDebug>
#include <QGridLayout>
int main(int argc, char *argv[])
{

QApplication a(argc, argv);
QWidget qw;
QList<QLineEdit*> list;
for(int i = 0; i < 2; i++) {
list.append(new QLineEdit());
}
QGridLayout *ql = new QGridLayout();
for(int a = 0; a < list.count; a++) {
ql->addWidget(list[a]);
}
qw.setLayout(ql);
qw.setFixedSize(200, 200);
qw.show();

QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("localhost");
db.setDatabaseName("test");
db.setUserName("root");
db.setPassword("secret");
bool ok = db.open();
if(ok) {

}
return a.exec();
}


And error:


/home/marcus/untitled-build-desktop-Qt_4_8_1_in_PATH__System__Release/../untitled/main.cpp:18: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<'


I think the problem is in the for loop with list.count
Ty for answer.

Added after 1 3 minutes:

Too late, fixed xd

it was list.count() not list.count