class ImageButton : public QGraphicsWidget
{
Q_OBJECT
public:
ImageButton(const QPixmap &pixmap, QGraphicsItem *parent = 0);
这是构造函数的声明。
ImageButton::ImageButton(const QPixmap &pixmap, QGraphicsItem *parent)
: QGraphicsWidget(parent), _pix(pixmap)
{}
这是cpp中构造函数。
谁能跟我解释哈,为什么通过这个构造函数就能把new出来的button绑定到Iitem了。比如:
ImageButton *btn1 = new ImageButton(QPixmap(A_PATH), buttonfather);
ImageButton *btn2 = new ImageButton(QPixmap(B_PATH), buttonfather);
ImageButton *btn3 = new ImageButton(QPixmap(C_PATH), buttonfather);
我现在想调查清楚有没有不通过构造函数来绑定到一个item里的方法。 我写的容器里已经有了的ImageButton,如何绑定到QGraphicsItem里呢?
求大神解释。