×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Nokia Developer Champion
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Unhappy 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??

  2. #2
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    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();
    }

  3. #3
    Nokia Developer Champion
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    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();
    }


    The png image is 163 x 49. S60_5th_Edition_SDK_v1.0, Qt 4.6.0.

  4. #4
    Nokia Developer Champion
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Buttons are driving me crazy-er

    Here's the icon:


  5. #5
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Buttons are driving me crazy-er

    Then it's correct. Manipulate iconSize to make it bigger on the button.
    http://doc.trolltech.com/4.6/qabstra...#iconSize-prop

  6. #6
    Nokia Developer Champion
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Buttons are driving me crazy-er

    OK, I insert "button.setIconSize(QSize(163,49));" and get this:



    But that's not what I want. I want the icon to BE the button, with the background showing around the edges.

  7. #7
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    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");

  8. #8
    Nokia Developer Champion
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Buttons are driving me crazy-er

    How do you animate that -- have separate images for pressed and released?

  9. #9
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Buttons are driving me crazy-er


  10. #10
    Nokia Developer Champion
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Buttons are driving me crazy-er

    Thanks for your help! I'm slowly getting it worked out.

Similar Threads

  1. Style sheets are driving me crazy
    By danhicksbyron in forum Qt
    Replies: 7
    Last Post: 2010-01-24, 05:31
  2. Dialog buttons not displayed
    By juannoguera in forum Symbian User Interface
    Replies: 0
    Last Post: 2009-11-16, 07:46
  3. n96 is driving me crazy, please help.......
    By nikkoSH in forum Mobile Java General
    Replies: 17
    Last Post: 2009-03-27, 17:13
  4. J2ME MIDP2 soft buttons
    By arikoivisto in forum Mobile Java Tools & SDKs
    Replies: 7
    Last Post: 2008-12-01, 18:22
  5. Rogue key event trap driving me crazy
    By slitchfield in forum Symbian
    Replies: 1
    Last Post: 2007-08-12, 16:40

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •