Declare const array of struct
Unsolved
General and Desktop
-
Hello,
I have the following code in cpp file:
#include "xxx.h" typedef struct { int icon; QRect geometry; int layer; QString iconName; } icon_s; const icon_s icon[] = { { 1, QRect(0,0,10,10), 1, "iconName1.png" }, { 2, QRect(10,10,10,10), 1, "iconName2.png"} }; //Here begins the constructor of the class MyWidget::MyWidget(QWidget *parent) : QDialog(parent), ui(new Ui::MyWidget) { ... ... } void MyWidget::placeIcon() { int iconNumber = icon[0].icon; .. QString file = icon[0].iconName; .. .. }
What I would like to know if this is the correct way in QT to define this kind of const ?
Thanks in advance..
Regards
-
@ploef said:
Hi
Except that typedef struct is a bit c-ish ,
then its a fine method. :)http://stackoverflow.com/questions/612328/difference-between-struct-and-typedef-struct-in-c