I wanted to create a file which has all the KeyPairs I need to use in a program. However, I figured it would be better to have it embedded in the code, so instead, I want to put it in a struct. For example, how do I put this items explicitly in a struct?
{Qt::Key_0, "Win1"},
{Qt::Key_1, "Win2"},
{Qt::Key_2, "Win3"},
{Qt::Key_3, "Win4"},
{Qt::Key_4, "Win5"},
{Qt::Key_5, "Win6"},
{Qt::Key_6, "Win1"},
{Qt::Key_7, "Win7"},
{Qt::Key_8, "Win3"},
{Qt::Key_9, "Win5"}
how do I access these items too?
Just declare the struct, and initialize it:
Here, I’ve assumed that the
Qt::Key_0and so on values are values of the type Key enumeration, which seems reasonable given your usage. If you need to refer to the struct type itself somewhere, you need to give it a struct tag (=class name, in C++) too; I omitted that for brevity.Access is like for any other array: