QDebug seem to not find overload ? - QMap



  • 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?


  • Moderators

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.