Results 1 to 3 of 3

Thread: const QStringList discards qualifiers

  1. #1
    Join Date
    Jan 2006
    Posts
    46
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default const QStringList discards qualifiers

    Hello guys after googling a while and reading about references, I still can't get what's wrong with this. I'm getting two compiler error and both say:
    error: passing ‘const QStringList’ as ‘this’ argument of ‘QStringList& QStringList:perator<<(const QString&)’ discards qualifiers
    The code generating this error is:
    Qt Code:
    1. QString DBMigrator::parsePostGISSrcFields(const TableInfo *tableInfo, const bool &ignore) const
    2. {
    3. GeometryColumnInfo *column;
    4. QStringList fields;
    5. QString field;
    6.  
    7. foreach(field, tableInfo->fieldNames())
    8. {
    9. foreach(column, geometryColumns[tableInfo->name()])
    10. {
    11. if (field == column->columnName())
    12. {
    13. if (!ignore)
    14. {
    15. this->ignoredFields << field;
    16. }
    17. else
    18. {
    19. fields << QString("AsText(%1)").arg(field);
    20. this->geometryFields << field;
    21. }
    22. }
    23. else
    24. {
    25. fields << field;
    26. }
    27. }
    28. }
    29. // qDebug(QString("%1:\n %2").arg(tableInfo->name()).arg(fields.join(", ")).toAscii());
    30.  
    31. return fields.join(", ");
    32. }
    To copy to clipboard, switch view to plain text mode 
    And the lines are where appending QStrings to the QStringLists (this->geometryFields, this->ignoredFields) both QStringLists are private to the class.

    I don't know what's wrong, what confuses me more, is that if I declare a QStringList local to this method and do the append operations on that QStringList, I got no error.

    Can anybody explain me what's happening, what am I doing wrong? or point me to a document that explains something like this?

    Thanx a lot in advance.

    Cheers.
    Last edited by kandalf; 24th January 2009 at 23:30. Reason: updated contents
    Kandalf
    There's no place like ~

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: const QStringList discards qualifiers

    How are your this->ignoredFields and this->geometryFields declared ??
    I see that your function is const member function.

    So if you are modifying ur member variables in this function, they should be mutable .
    Are your this->ignoredFields and this->geometryFields mutable ? if not , declare mutable and try.

  3. The following user says thank you to aamer4yu for this useful post:

    kandalf (25th January 2009)

  4. #3
    Join Date
    Jan 2006
    Posts
    46
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: const QStringList discards qualifiers

    Thanx a lot. I had a misconception of const functions.
    Just for information purposes, I did declared mutable and it worked, but I redeclare my function to not to be const, since it had no point to be const.

    Thanx a lot again.

    Cheers.
    Kandalf
    There's no place like ~

Similar Threads

  1. QSql*Model + QTreeView : make a tree
    By punkypogo in forum Qt Programming
    Replies: 18
    Last Post: 24th October 2008, 18:14
  2. shared vs static
    By alisami in forum Installation and Deployment
    Replies: 3
    Last Post: 4th October 2008, 13:04
  3. qt 4.2.2 install in tru64 cxx
    By try to remember in forum Installation and Deployment
    Replies: 0
    Last Post: 30th March 2007, 07:43
  4. QTableView paints too much
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 26th July 2006, 18:42
  5. Delegates and Table
    By ankurjain in forum Qt Programming
    Replies: 8
    Last Post: 18th May 2006, 19:47

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.