How I can define a QMap with struct as key

  c++, qmap, qt

I try to define a QMap which it’s key is a C++ structure.

struct ProcInfo_S
{
    quint8 tech = 0;
    quint8 direction = 0;
    quint8 category = 0;
};

QMap<ProcInfo_S, uint64_t> G;
G[{2,3,4}] = 2;

But when I compile this code, I get the following compile error:

error: no match for ‘operator<’ (operand types are ‘const MainWindow::MainWindow(QWidget*)::ProcInfo_S’

Source: Windows Questions C++

LEAVE A COMMENT