Hi,
I am using QT 4.1 on windows
I want to my button as round shape (Based on image type).
Please help me!!!
Hi,
I am using QT 4.1 on windows
I want to my button as round shape (Based on image type).
Please help me!!!
It can be simply achieved with style sheets:
Sample from Qt Documentation. More here: http://doc.trolltech.com/4.6/stylesheet.htmlQt Code:
button->setStyleSheet(" border-image: url(button.png) 3 10 3 10; border-top: 3px transparent; border-bottom: 3px transparent; border-right: 10px transparent; border-left: 10px transparent; ");To copy to clipboard, switch view to plain text mode
Oleg Shparber
You can also use QWidget::setMask().
Hi I have tried this example ..but its not working ... Button.png is in my App folder and debug folder also...
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel topLevelLabel;
QPixmap pixmap(":/button.png");
topLevelLabel.setPixmap(pixmap);
topLevelLabel.setMask(pixmap.mask());
topLevelLabel.show();
return app.exec();
}
You could refer to the shaped clock example in Qt Demo,,, instead of the widget, you can have QPushButton.
you have provided the wrong path to button.png.
":/button.png" means the file is located in the qt resource file and not the current/debug dir.
hi I have tried with your example but still its n not working ..here is my code
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QPushButton *button = new QPushButton();
button->setStyleSheet("border-image: url(:/button.png) 3 10 3 10;border-top: 3px transparent;border-bottom: 3px transparent; border- right: 10px transparent;border-left: 10px transparent;");
button->show();
return app.exec();
}
button.png is in my application folder and in debug folder also....
Bookmarks