Can you verify that the following code gives you what you want?
#include <QtGui>
int main(int argc, char *argv[])
{
app.
setStyle(QApplication::setStyle("Plastique"));
// not related to bug prolly
// Changed these three lines
qb
->setMinimumSize
(QSize(66,
47));
qb
->setMaximumSize
(QSize(66,
47));
qb->setStyleSheet("border-image: url(test.png) 0 0 0 0 stretch; border-width: 2;");
qddd->show();
return app.exec();
}
#include <QtGui>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
app.setStyle(QApplication::setStyle("Plastique")); // not related to bug prolly
QDialog* qddd;
qddd = new QDialog;
QPushButton* qb = new QPushButton("Test", qddd);
// Changed these three lines
qb->setMinimumSize(QSize(66, 47));
qb->setMaximumSize(QSize(66, 47));
qb->setStyleSheet("border-image: url(test.png) 0 0 0 0 stretch; border-width: 2;");
qddd->show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Works like a charm with Qt 4.3.0 on my Linux box.
All I did was read the Qt 4.3.0 Documentation and follow the link to the CSS Draft Specification for details.
Note that this code is still using border-image, so it's still not the correct thing even if it works. It can break in the future. The correct code would use background-image in combination with background-size. Check the CSS Specification for details. Unfortunately Qt 4.3.0 (nor 4.2.3) doesn't support the background-size property (yet). This you can report to Trolltech as a feature suggestion and they might add support for it in the future.
Note that because of the border-width property I've added 4px to the image width and height. If you shrink the button smaller than this size it won't look nice. I'm sure the same is the case with Qt 4.2.3.
I hope this makes up for using the f-word in an earlier post.
Bookmarks