|
显示图片的程序是如何实现的.我用下面的方法可是不起作用!
#include<qpixmap.h>
#include<qwidget.h>
#include<qapplication.h>
#include<qvbox.h>
#include<qlabel.h>
class MyLabel : public QLabel
{
public:
MyLabel(QLabel *parent=0,const char *name=0);
};
MyLabel::MyLabel(QLabel *parent,const char *name)
: QLabel(parent,name)
{
QPixmap *pix = new QPixmap();
pix -> load("bird.bmp");
pix -> resize(622,98;
}
class MyWidget : public QVBox
{
public:
MyWidget(QWidget *parent=0,const char *name=0);
};
MyWidget::MyWidget(QWidget *parent,const char *name)
: QVBox(parent,name)
{
MyLabel *pic = new MyLabel();
connect(pic,SIGNAL(clicked()),qApp,SLOT(setPixmap()));
// pic -> indent(Qt::AlignHCenter);
}
}
int main(int argc , char **argv)
{
QApplication a(argc,argv);
MyWidget w;
w.setGeometry(0,0,622,220);
a.setMainWidget( &w );
w.show();
return a.exec();
} |
|