Just trying to understand why I'm not getting an error here. The QAbstractButton's (well actually I'm using the QPushButton, but I assume it's the same either way) member function setIcon takes a QIcon argument...
The function looks like: void setIcon(const QIcon &icon)
and I don't think it's overloaded. So why is it that I can call the function and give it a QPixmap as an argument, but not get an error?
This line: PB->setIcon(QPixmap());
, where PB
is a QPushButton object, does not give me an error and I just want to know why because I'm new to C++ and maybe I'm missing something more fundamental. Any help is appreciated!
You don't get an error, because the QPixmap()
argument you give to the setIcon()
function implicitly converted to a QIcon
object. Or, better to say, compiler implicitly creates a QIcon
object out of a QPixmap
, as the following constructor exists:
QIcon::QIcon(const QPixmap &)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.