Results 1 to 2 of 2

Thread: QToolButton icon size is not fitting the buttons' dimensions

  1. #1
    Join Date
    Sep 2011
    Location
    Bangalore
    Posts
    254
    Thanks
    92
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default QToolButton icon size is not fitting the buttons' dimensions

    I have added a QToolButton to a QWidget on a QToolBar. Now I'm trying to add a icon to the QToolButton, but the icon is not fitting the buttons' dimensions even though the size of the button is almost same as the button. I'ev added the image in resource file under :/imgs/. Below I've produced the code for perusal.
    Kindly help me with this. Thank you.

    Qt Code:
    1. m_pbSummary = new QToolButton();
    2. m_pbSummary->setFixedSize(SUMMARY_BUTTON_WIDTH, SUMMARY_BUTTON_HEIGHT);
    3. m_pbSummary->setStyleSheet("QToolButton {color: #333; border: 2px solid #555; border-radius: 11px; padding: 5px; background: qradialgradient(cx: 0.3, cy: -0.4,fx: 0.3, fy: -0.4, radius: 1.35, stop: 0 #fff, stop: 1 #888); min-width: 80px;}"
    4. "QToolButton:hover {background: qradialgradient(cx: 0.3, cy: -0.4, fx: 0.3, fy: -0.4, radius: 1.35, stop: 0 #fff, stop: 1 #bbb);}"
    5. "QToolButton:pressed { background: qradialgradient(cx: 0.4, cy: -0.1, fx: 0.4, fy: -0.1, radius: 1.35, stop: 0 #fff, stop: 1 #ddd);}");
    6.  
    7. m_pbSummary->setToolButtonStyle(Qt::ToolButtonIconOnly);
    8. m_pbSummary->setIcon(QIcon(":/imgs/summary.png"));
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Sep 2011
    Location
    Bangalore
    Posts
    254
    Thanks
    92
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: QToolButton icon size is not fitting the buttons' dimensions

    I've solved it by using setIconSize().
    Thank you.

Similar Threads

  1. QtoolButton icon change on focus
    By Charvi in forum Qt Programming
    Replies: 1
    Last Post: 30th August 2012, 13:00
  2. Replies: 0
    Last Post: 23rd March 2011, 05:07
  3. QToolButton icon did not appear
    By mismael85 in forum Qt Programming
    Replies: 4
    Last Post: 24th March 2008, 18:13
  4. QToolButton icon not updated in overflow menu
    By pabakertx in forum Qt Programming
    Replies: 2
    Last Post: 26th September 2007, 13:48
  5. QToolButton will not display its icon
    By JimBrown in forum Qt Programming
    Replies: 6
    Last Post: 9th March 2007, 18:54

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.