PDA

View Full Version : syntax error : identifier 'QSqlRelationalDelegate'


sticcino
1st July 2008, 23:52
Hi,

For some reason, i cannot access the QSqlRelationalDelegate method, either in my code or with the sample code.

For example this code from the sample:

QTableView *view = new QTableView;
view->setModel(model);
view->setItemDelegate(new QSqlRelationalDelegate(view));

i get a syntax error : identifier 'QSqlRelationalDelegate' error when compliing with VS2005.

Or with:

model = new QSqlRelationalTableModel(this, m_pPrimarydb);

model->setTable(tableName);
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
model->setRelation(18, QSqlRelation("Category", "mCategoryID", "mCategoryName"));

model->select();

m_pMusicTableView->setModel(model);

m_pMusicTableView->setItemDelegate(new QSqlRelationalDelegate(m_pMusicTableView));

m_pMusicTableView->show();



All other sql functions seem to be working with no problem. (qsqldatabase, qsqlquery.. etc)

I have no clue what I have forgotten to include to get this to compile, any help appreciated.

Thanks,
Johnny

wysota
2nd July 2008, 00:58
Did you remember to #include <QSqlRelationalDelegate> ?

sticcino
2nd July 2008, 16:24
I did.
What's killing me is that the examples have compiled when I compiled QT. I used vs2005 from the command line.
the funny tthing also is that if I take the complete sql example relationaltable.cpp and paste it into my files, it also fails with the same error.

Johnny

wysota
2nd July 2008, 20:49
Did you enable the SQL module for your project?

sticcino
3rd July 2008, 02:02
Hi,

I did as i'm using the sql modules reguarly.

Johnny

wysota
3rd July 2008, 08:35
Try rewriting the messing code line manually - sometimes you might be pasting some weird whitespaces from an external source and the compiler will complain.