Discussion Board

Results 1 to 10 of 10

Hybrid View

  1. #1
    Nokia Developer Champion danhicksbyron's Avatar
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209
    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 divanov's Avatar
    Join Date
    Oct 2009
    Posts
    4,326
    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 danhicksbyron's Avatar
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209
    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 danhicksbyron's Avatar
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209
    Here's the icon:


  5. #5
    Nokia Developer Moderator divanov's Avatar
    Join Date
    Oct 2009
    Posts
    4,326
    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 danhicksbyron's Avatar
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209
    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.

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 Python
    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
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved