Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 347413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:16:06+00:00 2026-05-12T11:16:06+00:00

On the iPhone, you give it your 45×45 flat image for the app icon,

  • 0

On the iPhone, you give it your 45×45 flat image for the app icon, and the SDK rounds and highlights it for you automatically, giving it a new 3D effect. Does anyone have sample code or recommendations on how to emulate this using Qt4 APIs? Thanks, –DD

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T11:16:06+00:00Added an answer on May 12, 2026 at 11:16 am

    I’m not sure a style sheet could do all you are asking for, if you want the full effect of the iphone app icons: the rounded rectangle, the subtle gradient to give it the 3D look, and the shine. But perhaps it could, if you could overlay two images on top of one another. One could be the rounded 3D mask image with transparency, then you just put your 45X45 image behind it. But then, I don’t know how extensible qstylesheets are at this point.

    However, another alternative is to use QPainter. It can definitely do all you require. Basically what you would want to do is override the paintEvent() of your widget, QPushButton, QLabel…etc. and draw it yourself using the source image. Here is a link to a wiki entry I did on custom-painting a QPushButton to give it an Windows Aero look, which is not dissimilar to the iphone app icon: http://wiki.qtcentre.org/index.php?title=AeroButton

    And here is the paintEvent() from the class, to give you a starting point. Once you get into it, using the Assistant, it’s pretty straightforward:

     void AeroButton::paintEvent(QPaintEvent * pe)
     {
         Q_UNUSED(pe);
    
         QPainter painter(this);  
         painter.setRenderHint(QPainter::Antialiasing);
    
         //test for state changes
         QColor button_color;
         if(this->isEnabled())
         {
             m_hovered ? button_color = m_highlight : button_color = m_color;
    
             if(m_pressed)
             {
                  button_color = m_highlight.darker(250);
             }
         }
         else
         {
             button_color = QColor(50, 50, 50);
         }
    
         QRect button_rect = this->geometry();
    
         //outline
         painter.setPen(QPen(QBrush(Qt::black), 2.0));
         QPainterPath outline;
         outline.addRoundedRect(0, 0, button_rect.width(), button_rect.height(), m_roundness, m_roundness);
         painter.setOpacity(m_opacity);
         painter.drawPath(outline);
    
         //gradient
         QLinearGradient gradient(0, 0, 0, button_rect.height());
         gradient.setSpread(QGradient::ReflectSpread);
         gradient.setColorAt(0.0, button_color);
         gradient.setColorAt(0.4, m_shadow);
         gradient.setColorAt(0.6, m_shadow);
         gradient.setColorAt(1.0, button_color);
    
         QBrush brush(gradient);
         painter.setBrush(brush); 
         painter.setPen(QPen(QBrush(button_color), 2.0));
    
         //main button
         QPainterPath painter_path;
         painter_path.addRoundedRect(1, 1, button_rect.width() - 2, button_rect.height() - 2, m_roundness, m_roundness);
         painter.setClipPath(painter_path);
    
         painter.setOpacity(m_opacity);
         painter.drawRoundedRect(1, 1, button_rect.width() - 2, button_rect.height() - 2, m_roundness, m_roundness);
    
         //glass highlight
         painter.setBrush(QBrush(Qt::white));
         painter.setPen(QPen(QBrush(Qt::white), 0.01));
         painter.setOpacity(0.30);
         painter.drawRect(1, 1, button_rect.width() - 2, (button_rect.height() / 2) - 2);
    
         //text
         QString text = this->text();
         if(!text.isNull())
         {
             QFont font = this->font();
             painter.setFont(font);
             painter.setPen(Qt::white);
             painter.setOpacity(1.0);
             painter.drawText(0, 0, button_rect.width(), button_rect.height(), Qt::AlignCenter, text);
         }
    
          //icon
          QIcon icon = this->icon();
          if(!icon.isNull())
          {
             QSize icon_size = this->iconSize();
             QRect icon_position = this->calculateIconPosition(button_rect, icon_size);
             painter.setOpacity(1.0);
             painter.drawPixmap(icon_position, QPixmap(icon.pixmap(icon_size)));
          }
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to give zoom effect to the iPhone camera image while capturing the
I am implementing map based application in iPhone sdk. I want to give functionality
In my Iphone app I give a button when pressed calls a specific number
Can you give me a starter point for creating an iphone app that recognises
How to give multiple header search path in iphone SDK? I mean what is
I am developing an iPhone app for music. I want to give some options
Possible Duplicate: How do you prompt the user to rate your iphone app without
I am trying to get an iPhone app packaged up. (I'm very new to
For an iPhone App I decided to give a try to a NoSQL DB,
I'm very keen to learn Iphone apps development. Can you experts give me some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.