Hi all,
I am trying to create round shaped/smooth edged push buttons with bitmap on It. Here is the code I had written,
#include <QtGui>
#include <QApplication>
#include <QPushButton>
#include <Qt>
QPushButton *customButton(QString,QString );
int main(int argc, char *argv[]){
QApplication myapp(argc,argv);
QWidget *mywidget = new QWidget;
QPushButton *first=customButton("f1u7.png", "first");
QPushButton *second=customButton("f1u8.png","second");
QHBoxLayout *mylayout= new QHBoxLayout(mywidget);
mylayout->addWidget(first);
mylayout->addWidget(second);
mywidget->setLayout(mylayout);
mywidget->show();
return myapp.exec();
}
QPushButton *customButton(QString str,QString str1)
{
QPushButton *pushButton= new QPushButton;
pushButton->setGeometry(10,10,100,100);
pushButton->clearMask();
pushButton->setBackgroundRole( QPalette::Base);
QPixmap mypixmap; mypixmap.load(str);
QBitmap bm = mypixmap.createHeuristicMask();
pushButton->setFixedSize( mypixmap.width(), mypixmap.height() );
pushButton->setMask( bm );
pushButton->setIcon(mypixmap);
pushButton->setIconSize(QSize(mypixmap.height(),mypixmap.widt h()));
pushButton->setToolTip(str1);
return pushButton;
}
Bitmap appears on the button but with strange visual effect. Corners of button looks strange and some times dots appear on the border of the button. Would some body explain, the right way of doing it?
Thanks in advance,
Seema Rao
Bookmarks