一个简单例子:
class Button;
class Widget : public QWidget
{
Q_OBJECT
public:
Widget(QWidget *parent = 0);
private:
Button *botton;
};
//实现方法
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
botton = new Button(this);
botton->set_X_Y_width_height(10,10,80,30); //设置button停靠位置和大小
//设置button原图片,按下时图片,抬起时图片
botton->setButtonPicture(QPixmap("d:\\1.png"));
botton->setPressPicture(QPixmap("d:\\2.png"));
botton->setReleasePicture(QPixmap("d:\\3.png"));
}