PDA

View Full Version : syntax error : identifier 'QSqlRelationalDelegate'



sticcino
1st July 2008, 22: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
1st July 2008, 23:58
Did you remember to #include <QSqlRelationalDelegate> ?

sticcino
2nd July 2008, 15: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, 19:49
Did you enable the SQL module for your project?

sticcino
3rd July 2008, 01:02
Hi,

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

Johnny

wysota
3rd July 2008, 07: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.

R-Type
16th September 2011, 10:15
I just had the same problem. Solution is:
Go to Project -> Properties -> Configuration Properties -> C/C++ -> Preprocessor
Add QT_GUI_LIB to Preprocessor Definitions.
(taken from http://truth2.wordpress.com/2010/09/08/qsqlrelationaldelegate-visual-studio-compile-error/)