私は構造体を持っています:
typedef struct
{
Qt::Key qKey;
QString strFormType;
} KeyPair;
次に、KeyPair のインスタンス化を初期化して、Automated Test App で使用できるようにします。
KeyPair gDial[] =
{
{ Qt::Key_1 , "MyForm" },
{ Qt::Key_1 , "SubForm" },
{ Qt::Key_Escape, "DesktopForm" }
};
KeyPair gIP[] =
{
{ Qt::Key_1 , "MyForm" },
{ Qt::Key_2 , "Dialog" },
{ Qt::Key_2 , "Dialog" },
{ Qt::Key_Escape, "DesktopForm" }
};
....
and like 100 more instantiations....
現在、これらのキーペアを使用する関数を呼び出しています。
qDebug() << "Testing Test Menu";
pressKeyPairs( gDial);
qDebug() << "Testing Browse Menu";
pressKeyPairs( gIP);
....
and more calls like this for the rest...
これらすべての KeyPair インスタンス化を MAP に入れたいので、pressKeyPairs() と qDebug() を 100 回呼び出す必要はありません...私は MAPS を使用する初心者です...だから私は試しました:
map<string,KeyPair> mMasterList;
map<string,KeyPair>::iterator it;
mMasterList.insert( pair<string, KeyPair>("Testing Test Menu", *gDial) ); //which I know is wrong, but how?
mMasterList.insert( pair<string, KeyPair>("Testing IP Menu", *gIP) );
mMasterList.insert( pair<string, KeyPair>("IP Menu2", *gIP2) );
....
for ( it=mMasterList.begin() ; it != mMasterList.end(); it++ )
{
qDebug() << (*it).first << endl;
pressKeyPairs((*it).second);
// I don't know how to access .second ... this causes a compiler error
}
編集: pressKeyPairs は次のように宣言されます。
template <size_t nNumOfElements> void pressKeyPairs(KeyPair (&keys)[nNumOfElements]);
このコード ブロックは機能していません... :( これらのキーペアをマップに適切に配置する方法を誰か教えてもらえますか?