Results 1 to 20 of 25

Thread: #include <QString> error

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: #include <QString> error

    It should be:
    QT = core sql gui
    or simply
    QT += sql
    (core and gui modules are enabled by default).
    J-P Nurmi

  2. The following user says thank you to jpn for this useful post:

    vieraci (28th October 2007)

  3. #2
    Join Date
    Apr 2007
    Location
    Sunny Darwin, NT Australia
    Posts
    186
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: #include <QString> error

    Quote Originally Posted by jpn View Post
    It should be:

    or simply

    (core and gui modules are enabled by default).
    Thanks jpn,
    That fixed the problem I started with, now I'm left with the other problem I just posted.

  4. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: #include <QString> error

    I suppose you should add areacodescombobox.h and areacodescombobox.cpp to clientNotebook.pro.
    J-P Nurmi

  5. #4
    Join Date
    Apr 2007
    Location
    Sunny Darwin, NT Australia
    Posts
    186
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: #include <QString> error

    Quote Originally Posted by jpn View Post
    I suppose you should add areacodescombobox.h and areacodescombobox.cpp to clientNotebook.pro.
    It is already. Look at posted code above.

  6. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: #include <QString> error

    Quote Originally Posted by vieraci View Post
    It is already. Look at posted code above.
    Oh, I thought you said it was a plugin.. Anyway, did you actually implement a function body for AreacodesCombobox constructor?
    J-P Nurmi

  7. #6
    Join Date
    Apr 2007
    Location
    Sunny Darwin, NT Australia
    Posts
    186
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: #include <QString> error

    Yes the notebook part IS a plugin, and no, I didn't provide a constructor. I thought a default constructor might be provided by Qt... I just implemented the extra functions I need for the comboBox.

    The .h file is in this post, this is the cpp file:

    Qt Code:
    1. void AreacodesCombobox::initializeFields()
    2. {
    3. QString blank = " ";
    4. setSelectedAreacode(blank);
    5. setSelectedLocale(blank);
    6. clear();
    7. }
    8.  
    9. void AreacodesCombobox::on_returnPressed()
    10. {
    11. QString aLocale=currentText();
    12. if ((aLocale.trimmed().length() > 1) && (aLocale != QString(selectedLocale()).toUpper()))
    13. {
    14. QString searchText= ("UCASE(locale) like '%");
    15. searchText.append(aLocale.trimmed().toUpper());
    16. searchText.append("%' order by LOCALE");
    17. QString clause = searchWordsClause(aLocale, "locale", "AND", false,"locale");
    18. clause.prepend("SELECT Areacode, Locale FROM AreacodesView WHERE ");
    19. clause.append(" Order by Locale");
    20. QSqlQuery query(clause);
    21. if (query.isActive()) // successful execution
    22. {
    23. if (query.size()==0)
    24. {
    25. QApplication::beep ();
    26. QMessageBox::warning(this, tr("Postcode Search"),
    27. tr("No match found.\nCheck the spelling and try again."), QMessageBox::Ok);
    28. setFocus();
    29. }
    30. else
    31. {
    32. clear();
    33. while (query.next())
    34. {
    35. QString locale = query.value(0).toString();
    36. addItem(locale);
    37. }
    38. if (query.size()==1)
    39. QComboBox::setCurrentIndex(1);
    40. else
    41. {
    42. // comboBox()->select(1, true);
    43. QComboBox::showPopup();
    44. }
    45. }
    46. }
    47. else
    48. {
    49. QApplication::beep ();
    50. QMessageBox::warning(this, tr("SQL Error"),
    51. query.lastError().text(), QMessageBox::Ok);
    52. }
    53. // else if (model->query().isSelect()) // is a select statement
    54. }
    55. }
    To copy to clipboard, switch view to plain text mode 

  8. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: #include <QString> error

    Quote Originally Posted by vieraci View Post
    Yes the notebook part IS a plugin
    But template is "app" and it has main()..?

    Quote Originally Posted by vieraci View Post
    and no, I didn't provide a constructor. I thought a default constructor might be provided by Qt... I just implemented the extra functions I need for the comboBox.
    C++ compilers provide a default constructor in case you don't provide one. But in case you declare anything, you must also implement it:
    Qt Code:
    1. AreacodesCombobox::AreacodesCombobox(QWidget *parent) : QComboBox(parent)
    2. {
    3. // ...
    4. }
    To copy to clipboard, switch view to plain text mode 

    Quote Originally Posted by vieraci View Post
    The .h file is in this post, this is the cpp file:
    In case that's really the full .cpp, looks like you're missing implementations of a bunch of other functions as well; setSelectedLocale(), setSelectedAreacode(), selectedLocale(), selectedAreacode().
    J-P Nurmi

  9. #8
    Join Date
    Apr 2007
    Location
    Sunny Darwin, NT Australia
    Posts
    186
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: #include <QString> error

    Quote Originally Posted by jpn View Post
    But template is "app" and it has main()..?
    I created it by followed the example in the docs, now I can't find it, but from memory there was a "main" and template was "app"...but that probably doesn't mean it's correct.

    Quote Originally Posted by jpn View Post
    C++ compilers provide a default constructor in case you don't provide one. But in case you declare anything, you must also implement it:
    Qt Code:
    1. AreacodesCombobox::AreacodesCombobox(QWidget *parent) : QComboBox(parent)
    2. {
    3. // ...
    4. }
    To copy to clipboard, switch view to plain text mode 
    But do I really need a constructor here ? there's nothing special I need to implement there, I'm just adding custom code.

    Quote Originally Posted by jpn View Post
    In case that's really the full .cpp, looks like you're missing implementations of a bunch of other functions as well; setSelectedLocale(), setSelectedAreacode(), selectedLocale(), selectedAreacode().
    Yes, they're implemented, seems I didn't select the whole file when I copied.
    I actually was going to implement a constructor but thought about what I needed to do that was different, answer was "nothing" so I rem-ed it out.

    Qt Code:
    1. #include "./areacodescombobox.h"
    2. /*
    3. AreacodesCombobox::AreacodesCombobox()
    4. {
    5. }
    6. */
    7. const QString& AreacodesCombobox::selectedLocale() const
    8. {
    9. return vSelectedLocale;
    10. }
    11.  
    12. void AreacodesCombobox::setSelectedLocale(const QString& aSelectedLocale)
    13. {
    14. if (!(vSelectedLocale == aSelectedLocale))
    15. {
    16. vSelectedLocale = aSelectedLocale;
    17. }
    18. }
    19.  
    20. const QString& AreacodesCombobox::selectedAreacode() const
    21. {
    22. return vSelectedAreacode;
    23. }
    24.  
    25. void AreacodesCombobox::setSelectedAreacode(const QString& aSelectedAreacode)
    26. {
    27. if (!(vSelectedAreacode == aSelectedAreacode))
    28. {
    29. vSelectedAreacode = aSelectedAreacode;
    30. }
    31. }
    32. ...
    To copy to clipboard, switch view to plain text mode 

  10. #9
    Join Date
    Apr 2007
    Location
    Sunny Darwin, NT Australia
    Posts
    186
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: #include <QString> error

    So changing TEMPLATE = lib compiles ok, but a simmilar error message appears when I move into the plugin dir and attempt to make the plugin.

Similar Threads

  1. Error compiling psql plugin
    By vieraci in forum Installation and Deployment
    Replies: 4
    Last Post: 7th October 2007, 02:49
  2. qt 4.2.2 install on aix
    By try to remember in forum Installation and Deployment
    Replies: 2
    Last Post: 28th March 2007, 12:19
  3. Qt-x11-commercial-src-4.2.0-snapshot-20060824 error
    By DevObject in forum Installation and Deployment
    Replies: 4
    Last Post: 24th August 2006, 23:31
  4. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52
  5. Am I the only one with "make" error ?
    By probine in forum Installation and Deployment
    Replies: 1
    Last Post: 13th February 2006, 12:54

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
  •  
Qt is a trademark of The Qt Company.