C++ 无法在multiMap C+;中插入QCustomPlot::QCPGraph+;

C++ 无法在multiMap C+;中插入QCustomPlot::QCPGraph+;,c++,qt,plot,multimap,qcustomplot,C++,Qt,Plot,Multimap,Qcustomplot,我正在编写一个程序,需要将QCustomPlot框架中的QCPGraph插入std::multimap。注意:我对C++仍然很陌生。然而,我不能让它工作,这真的令人沮丧 这是我的密码: ui->customPlot->addGraph(); /* fill graph with some data */ QCPGraph *graph = ui->customPlot->graph(0); std::multimap<int, std::

我正在编写一个程序,需要将QCustomPlot框架中的
QCPGraph
插入
std::multimap
。注意:我对C++仍然很陌生。然而,我不能让它工作,这真的令人沮丧

这是我的密码:

ui->customPlot->addGraph();        

/*
  fill graph with some data
*/

QCPGraph *graph = ui->customPlot->graph(0); 

std::multimap<int, std::pair<std::vector<double>, QCPGraph>, _comparator> myMap; 

//just for demo
std::vector<double> vec; 
vec.at(0) = 2.2; 

myMap.insert(std::make_pair(1, std::make_pair(vec, graph)));
ui->customPlot->addGraph();
/*
用一些数据填充图表
*/
QCPGraph*graph=ui->customPlot->graph(0);
std::multimap myMap;
//只是为了演示
std::vec;
(0)处的向量=2.2;
insert(std::make_pair(1,std::make_pair(vec,graph));
最后一行给出了以下编译器错误:

C:\path\mainwindow.cpp:178: Error: no matching function for call to 'std::multimap<int, std::pair<std::vector<double>, QCPGraph>, MainWindow::__comparator>::insert(std::pair<int, std::pair<std::vector<double>, QCPGraph*> >)'
     myMap.insert(std::make_pair(1, std::make_pair(vec, graph)));
                                                                 ^

C:\Qt\Tools\mingw530_32\i686-w64-mingw32\include\c++\bits\stl_multimap.h:524: Error: no type named 'type' in 'struct std::enable_if<false, void>'
       template<typename _Pair, typename = typename
                                ^
C:\path\mainwindow.cpp:178:错误:调用“std::multimap::insert(std::pair)”时没有匹配的函数
insert(std::make_pair(1,std::make_pair(vec,graph));
^
C:\Qt\Tools\mingw530\u 32\i686-w64-mingw32\include\C++\bits\stl\u multimap.h:524:错误:在“struct std::enable\u if”中没有名为“type”的类型
模板您的容器是:

std::multimap<int, std::pair<std::vector<double>, QCPGraph>> myMap; 
您需要像这样插入它:

myMap.insert(std::make_pair(1, std::make_pair(vec, *graph)));
或者在C++11中:

myMap.emplace(1, std::make_pair(vec, *graph));
但我认为该图应该归QCustomPlot所有,因此您实际上应该存储一个指向它的指针:

std::multimap<int, std::pair<std::vector<double>, QCPGraph*>> myMap; 
myMap.emplace(1, std::make_pair(vec, graph));
std::multimap myMap;
放置(1,std::make_pair(vec,graph));
myMap.emplace(1, std::make_pair(vec, *graph));
std::multimap<int, std::pair<std::vector<double>, QCPGraph*>> myMap; 
myMap.emplace(1, std::make_pair(vec, graph));