Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QDebug seem to not find overload ? - QMap
QtWS25 Last Chance

QDebug seem to not find overload ? - QMap

Scheduled Pinned Locked Moved Solved General and Desktop
qdebugqmap
2 Posts 2 Posters 666 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dariusz
    wrote on 2 Apr 2019, 20:46 last edited by Dariusz 4 Feb 2019, 20:48
    #1

    Hey

    So I have this function :

    struct myTestColor {
        double h, s, v;
        inline QColor toColor() {
            QColor c;
            c.setHsv(h, s, v);
            return c;
        }
    };
    
    inline QDebug &operator<<(QDebug &deb, QMap<QString, myTestColor> &style) {
        deb << "\n\tSize : " << style.size();
        deb << "\n\tKeys : " << style.keys();
        int x = 0;
        for (auto &key:style.keys()) {
            deb << "\n\t" << ++x << " (" << key << " : " << style[key].toColor() << "),";
        }
        return deb;
    }
    
    inline QDebug &operator<<(QDebug &deb, QMap<QString, QMap<QString, myTestColor>> &style) {
        deb << "\nSize : " << style.size();
        deb << "\nKeys : " << style.keys();
        int x = 0;
        for (auto &key:style.keys()) {
            deb << "\n" << ++x << " (" << key << " : " << style[key] << "\n),";
        }
        return deb;
    }
    
    inline QDebug &operator<<(QDebug &deb, myTestColor &style) {
        deb << style.toColor();
        return deb;
    }
    

    and this container:

    QMap<QString,QMap<QString,myTestColor>> mList;
    

    if I do

    qDebug()<<mList;
    

    without having the 2 specific QMap qDebug overloads I get an debug error cant find matching bla bla bla... Its as if QMap debug could not find inline QDebug &operator<<(QDebug &deb, myTestColor &style) in first place and needed exact debug...

    This looks very strange to me and I never had that before... I think, its super weird! What did I do wrong here?

    R 1 Reply Last reply 2 Apr 2019, 20:53
    0
    • D Dariusz
      2 Apr 2019, 20:46

      Hey

      So I have this function :

      struct myTestColor {
          double h, s, v;
          inline QColor toColor() {
              QColor c;
              c.setHsv(h, s, v);
              return c;
          }
      };
      
      inline QDebug &operator<<(QDebug &deb, QMap<QString, myTestColor> &style) {
          deb << "\n\tSize : " << style.size();
          deb << "\n\tKeys : " << style.keys();
          int x = 0;
          for (auto &key:style.keys()) {
              deb << "\n\t" << ++x << " (" << key << " : " << style[key].toColor() << "),";
          }
          return deb;
      }
      
      inline QDebug &operator<<(QDebug &deb, QMap<QString, QMap<QString, myTestColor>> &style) {
          deb << "\nSize : " << style.size();
          deb << "\nKeys : " << style.keys();
          int x = 0;
          for (auto &key:style.keys()) {
              deb << "\n" << ++x << " (" << key << " : " << style[key] << "\n),";
          }
          return deb;
      }
      
      inline QDebug &operator<<(QDebug &deb, myTestColor &style) {
          deb << style.toColor();
          return deb;
      }
      

      and this container:

      QMap<QString,QMap<QString,myTestColor>> mList;
      

      if I do

      qDebug()<<mList;
      

      without having the 2 specific QMap qDebug overloads I get an debug error cant find matching bla bla bla... Its as if QMap debug could not find inline QDebug &operator<<(QDebug &deb, myTestColor &style) in first place and needed exact debug...

      This looks very strange to me and I never had that before... I think, its super weird! What did I do wrong here?

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 2 Apr 2019, 20:53 last edited by raven-worx 4 Feb 2019, 20:53
      #2

      @Dariusz
      your signature of the overload isn't correct: see this
      also make sure those implementations are in the corresponding header file

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      2

      1/2

      2 Apr 2019, 20:46

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved