怎么才能做出这样的Button效果?
像这样:
http://www.flickr.com/photos/79592362@N03/7327922458/in/photostream
我用下面的代码,只能显示方框,Button里面图片显示不出来
LayoutDlg::LayoutDlg(QWidget *parent, Qt::WindowFlags f)
: QDialog(parent,f)
{
setWindowTitle(tr("MyLayout is OK!"));
QPixmap *pixmap = NULL;
pixmap = new QPixmap(200, 150);
pixmap->load(":/images/heart.png");
QIcon *icon = new QIcon(*pixmap);
QPushButton *imageButton = new QPushButton(*icon, "", this);
imageButton->setIconSize(QSize(190, 150));
imageButton->setFixedSize(200, 150);
gridLayout = new QGridLayout(this);
gridLayout->addWidget(imageButton,0,1);
}
[解决办法]
我试了一下,你的代码基本可以把图片显示上来,问题可能出在这句:
pixmap->load(":/images/heart.png");