Results 1 to 7 of 7

Thread: syntax error : identifier 'QSqlRelationalDelegate'

  1. #1
    Join Date
    Jun 2008
    Location
    Canada
    Posts
    10
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Unhappy syntax error : identifier 'QSqlRelationalDelegate'

    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:

    Qt Code:
    1. QTableView *view = new QTableView;
    2. view->setModel(model);
    3. view->setItemDelegate(new QSqlRelationalDelegate(view));
    To copy to clipboard, switch view to plain text mode 

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

    Or with:
    Qt Code:
    1. model = new QSqlRelationalTableModel(this, m_pPrimarydb);
    2.  
    3. model->setTable(tableName);
    4. model->setEditStrategy(QSqlTableModel::OnManualSubmit);
    5. model->setRelation(18, QSqlRelation("Category", "mCategoryID", "mCategoryName"));
    6.  
    7. model->select();
    8.  
    9. m_pMusicTableView->setModel(model);
    10.  
    11. m_pMusicTableView->setItemDelegate(new QSqlRelationalDelegate(m_pMusicTableView));
    12.  
    13. m_pMusicTableView->show();
    To copy to clipboard, switch view to plain text mode 


    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
    Last edited by sticcino; 1st July 2008 at 22:55. Reason: added addtional explaination

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: syntax error : identifier 'QSqlRelationalDelegate'

    Did you remember to #include <QSqlRelationalDelegate> ?

  3. #3
    Join Date
    Jun 2008
    Location
    Canada
    Posts
    10
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: syntax error : identifier 'QSqlRelationalDelegate'

    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

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: syntax error : identifier 'QSqlRelationalDelegate'

    Did you enable the SQL module for your project?

  5. #5
    Join Date
    Jun 2008
    Location
    Canada
    Posts
    10
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: syntax error : identifier 'QSqlRelationalDelegate'

    Hi,

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

    Johnny

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: syntax error : identifier 'QSqlRelationalDelegate'

    Try rewriting the messing code line manually - sometimes you might be pasting some weird whitespaces from an external source and the compiler will complain.

  7. #7
    Join Date
    Sep 2010
    Posts
    22
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: syntax error : identifier 'QSqlRelationalDelegate'

    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/...compile-error/)

Similar Threads

  1. StyleSheet syntax checking
    By MarkoSan in forum Qt Programming
    Replies: 5
    Last Post: 30th June 2008, 10:09
  2. lib("dnsapi")
    By CHeader in forum Newbie
    Replies: 10
    Last Post: 16th February 2008, 19:21
  3. Refreshing syntax highlighting
    By jpn in forum Qt Programming
    Replies: 3
    Last Post: 26th July 2006, 20:09
  4. #ifndef syntax error
    By cbeall1 in forum Qt Programming
    Replies: 6
    Last Post: 14th February 2006, 09:29
  5. A Qt4 editor part with syntax highlighting and stuff?
    By mgoettsche in forum General Discussion
    Replies: 3
    Last Post: 22nd January 2006, 16:32

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.