Size of icons in QToolBar



  • 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



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



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.