kasmanit
1st September 2012, 23:00
Hello Everyone,
I Have a custom type, let say MyClassA
class MyClassA
{
function a();
function b();
....
};
Q_DECLARE_METATYPE(MyClassA);
In my program I use a QCombobox, so i have the need of a QVariant, so I use
MyClassA a
QVariant var = QVariant::fromValue(a);
My Question is, once I get back the QVariant, with the signal "currentindexchange" for example, how can I use the function of the class MyClassA, on the QVariant?
ThanksYou
Added after 23 minutes:
Ok So I have Found a solution, and for now, before another solution I'm doing:
QVariant var2 = ui->comboBox_3->itemData(index);
MyClassA classA = var2.value<MyClassA>();
Hope this will help someone
I Have a custom type, let say MyClassA
class MyClassA
{
function a();
function b();
....
};
Q_DECLARE_METATYPE(MyClassA);
In my program I use a QCombobox, so i have the need of a QVariant, so I use
MyClassA a
QVariant var = QVariant::fromValue(a);
My Question is, once I get back the QVariant, with the signal "currentindexchange" for example, how can I use the function of the class MyClassA, on the QVariant?
ThanksYou
Added after 23 minutes:
Ok So I have Found a solution, and for now, before another solution I'm doing:
QVariant var2 = ui->comboBox_3->itemData(index);
MyClassA classA = var2.value<MyClassA>();
Hope this will help someone