Hello Everyone,
I Have a custom type, let say MyClassA
class MyClassA
{
function a();
function b();
....
};
Q_DECLARE_METATYPE(MyClassA);
class MyClassA
{
function a();
function b();
....
};
Q_DECLARE_METATYPE(MyClassA);
To copy to clipboard, switch view to plain text mode
In my program I use a QCombobox, so i have the need of a QVariant, so I use
MyClassA a
MyClassA a
QVariant var = QVariant::fromValue(a);
To copy to clipboard, switch view to plain text mode
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>();
QVariant var2 = ui->comboBox_3->itemData(index);
MyClassA classA = var2.value<MyClassA>();
To copy to clipboard, switch view to plain text mode
Hope this will help someone
Bookmarks