Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Size of icons in QToolBar
Forum Updated to NodeBB v4.3 + New Features

Size of icons in QToolBar

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 6.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    farcat
    wrote on last edited by
    #1

    Hi,

    I amtrying to increase the size of icons in a QToolBar, but with no success. The images are showing in the buttons at (i think) 16x16. This is the code:

    @
    class ViewSelector(QtGui.QToolBar):
    def init(self, parent):
    super(ViewSelector, self).init(parent)
    self.setIconSize(QtCore.QSize(32, 32))
    self.buttongroup = QtGui.QButtonGroup(self)
    self.buttons = [QtGui.QPushButton(QtGui.QPixmap('config/icons/a.png'), None),
    QtGui.QPushButton(QtGui.QPixmap('config/icons/b.png'), None),
    QtGui.QPushButton(QtGui.QPixmap('config/icons/c.png'), None)]
    for index in range(len(self.buttons)):
    button = self.buttons[index]
    button.index = index
    button.clicked.connect(self.selectview)
    button.setMaximumSize(32, 32)
    button.setMinimumSize(32, 32)
    button.setCheckable(True)
    self.buttongroup.addButton(button)
    self.addWidget(button)
    self.buttons[1].setChecked(True)
    self.parentWidget().setView(1)

    def selectview(self):
        self.parentWidget().setView(self.sender().index)
    

    @

    The source images are 64x64. Is it possible to change the size of the icons (the method sitIconSize would indicate so)? If so, what am i missing?

    Cheers, Lars

    1 Reply Last reply
    0
    • H Offline
      H Offline
      Hostel
      wrote on last edited by
      #2

      In my C++ code this works:
      @
      buttons = new QToolBar( this );
      buttons->setIconSize( QSize( 32, 32 ) );
      buttons->setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); // you should set Qt::ToolButtonIconOnly
      @

      Maybe QToolBar is on widget which has fixed size with height under 32 px?

      1 Reply Last reply
      0
      • I Offline
        I Offline
        issam
        wrote on last edited by
        #3

        see the diagramscene example in your Qt installation directory (/usr/lib/Qt4)

        http://www.iissam.com/

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved