Luca Danieli Luca Danieli - 1 year ago 76
C++ Question

How to choose a method overload when converting from a QVariant argument?

I have a problem.
In my *.cpp I have the following function:

void QcWMenuBar::setItems( const QVariantList & items )
Q_FOREACH( const QVariant & item, items )
//addMenu( item );

Qt has got many different addMenu() functions and therefore my program doesn't know what function to use for a QVariant type.
I would need in this case an
addMenu(QMenu * item)

How do I tell Qt to use this function?

Answer Source

You have to obtain the value of the right type from the variant:

void QcWMenuBar::setItems(const QVariantList & items)
  for (auto & item: items) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download