PDA

View Full Version : Pass a QIcon as an argument to a function



aguleo
29th January 2014, 15:46
Hi
How do i pass a QIcon to a function in other class, so that it uses the icon, lets say, in a QPushButton.
I trie something like this:

void Form::setMyIcon(QIcon x)
{
ui->pushButton->setIcon(x);
}

Is this the way or just a wrong approach?
Thanks

anda_skoa
29th January 2014, 18:47
Is this the way or just a wrong approach?


Looks good. Ideally use the same argument signature as QAbstractButton::setIcon, i.e.



void Form::setMyIcon(const QIcon &x)


But your version works as well.

Cheers,
_