Buttons are driving me crazy-er
Second problem: I want to create a button with a custom icon. I create the icon, with normal and selected images (PNGs, with transparent borders), and set it into the button. But the button still displays with it's default greyish border around the icon image. How do I eliminate this??
Re: Buttons are driving me crazy-er
This code seems to work fine on my Fedora box with Qt 4.6.
[CODE]
#include <QApplication>
#include <QMainWindow>
#include <QPushButton>
#include <QIcon>
#include <QPixmap>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QMainWindow window;
QPixmap pixmap("test.png");
QIcon icon(pixmap);
QPushButton button(icon, "Button");
window.setCentralWidget(&button);
window.show();
return a.exec();
}
[/CODE]
Re: Buttons are driving me crazy-er
[CODE]#include <QApplication>
#include <QMainWindow>
#include <QPushButton>
#include <QIcon>
#include <QPixmap>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QMainWindow window;
QPixmap pixmap(":/images/button_leftarrow_normal.png");
QIcon icon(pixmap);
QPushButton button(icon, "Button");
window.setCentralWidget(&button);
window.show();
return a.exec();
}
[/CODE]
[IMG]http://farm5.static.flickr.com/4054/4296776900_afbee304fc.jpg[/IMG]
The png image is 163 x 49. S60_5th_Edition_SDK_v1.0, Qt 4.6.0.
Re: Buttons are driving me crazy-er
Here's the icon:
[IMG]http://farm3.static.flickr.com/2727/4296043221_4b78fec5fe_o.png[/IMG]
Re: Buttons are driving me crazy-er
Then it's correct. Manipulate iconSize to make it bigger on the button.
[url]http://doc.trolltech.com/4.6/qabstractbutton.html#iconSize-prop[/url]
Re: Buttons are driving me crazy-er
OK, I insert "button.setIconSize(QSize(163,49));" and get this:
[IMG]http://farm3.static.flickr.com/2705/4297099615_98a68329c1.jpg[/IMG]
But that's not what I want. I want the icon to BE the button, with the background showing around the edges.
Re: Buttons are driving me crazy-er
Ok, then you need to do something like this:
[CODE]
button.setStyleSheet("border-image: url(:test.png) 0 0 0 0");
[/CODE]
Re: Buttons are driving me crazy-er
How do you animate that -- have separate images for pressed and released?
Re: Buttons are driving me crazy-er
Please, read the documentation.
[url]http://doc.trolltech.com/4.6/stylesheet-examples.html#customizing-a-qpushbutton-using-the-box-model[/url]
Re: Buttons are driving me crazy-er
Thanks for your help! I'm slowly getting it worked out.