Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to access contents of initialized struct in a map
    primarykey
    data
    text
    <p>I have a struct: </p> <pre><code>typedef struct { Qt::Key qKey; QString strFormType; } KeyPair; </code></pre> <p>Now I initialize KeyPair instantiations so I could use it for my Automated Test App. </p> <pre><code>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.... </code></pre> <p>Currently, I call a function which uses these KeyPairs.</p> <pre><code>qDebug() &lt;&lt; "Testing Test Menu"; pressKeyPairs( gDial); qDebug() &lt;&lt; "Testing Browse Menu"; pressKeyPairs( gIP); .... and more calls like this for the rest... </code></pre> <p>I would like to put all these KeyPair instantiations in a MAP so I wouldn't have to call pressKeyPairs() and qDebug() a hundred times... I'm a newbie in using MAPS... so I tried: </p> <pre><code>map&lt;string,KeyPair&gt; mMasterList; map&lt;string,KeyPair&gt;::iterator it; mMasterList.insert( pair&lt;string, KeyPair&gt;("Testing Test Menu", *gDial) ); //which I know is wrong, but how? mMasterList.insert( pair&lt;string, KeyPair&gt;("Testing IP Menu", *gIP) ); mMasterList.insert( pair&lt;string, KeyPair&gt;("IP Menu2", *gIP2) ); .... for ( it=mMasterList.begin() ; it != mMasterList.end(); it++ ) { qDebug() &lt;&lt; (*it).first &lt;&lt; endl; pressKeyPairs((*it).second); // I don't know how to access .second ... this causes a compiler error } </code></pre> <p>EDIT: pressKeyPairs is declared as: </p> <pre><code>template &lt;size_t nNumOfElements&gt; void pressKeyPairs(KeyPair (&amp;keys)[nNumOfElements]); </code></pre> <p>This code block isn't working... :( Can somebody tell me how to properly put these KeyPairs in a Map? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload