[SOLVED] Make all toolbar buttons same clickable size
-
wrote on 30 Jul 2013, 13:32 last edited by
Hello,
I have a vertical toolbar that I have placed buttons with images in. I have tried making the button sizes all the same, however when I scroll over them, the clickable size (based on the scrolled over highlighted area) of the button seems to be different for all of them. It seems to be conforming to the size of the image placed in the button. The code I used for two of the buttons is as follows:
@ /Define size of icons/
QSize toolBarButtonSize;
toolBarButtonSize.setHeight(35);
toolBarButtonSize.setWidth(35);/*Create buttons and display icon/text for each*/ onButton = new QToolButton(toolBar); onButton->setIcon(QIcon("C:/on.png")); onButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); onButton->setIconSize(toolBarButtonSize); onButton->setText("On"); powerState = 0; runButton = new QToolButton(toolBar); runButton->setIcon(QIcon("C:/arrow_green.png")); runButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); runButton->setIconSize(toolBarButtonSize); runButton->setText("Run");@
It doesn't look to professional like this so I want to know how to make the actual clickable button the same size so that everything is uniform...
Thanks!
-
wrote on 30 Jul 2013, 14:48 last edited by
when you say you tried to make the icons the same size, are they the same size ?
you could try
@onButton->setMaximumSize(toolBarButtonSize);
runButton->setMaximumSize(toolBarButtonSize);@but if the images aren't the same size you might get some clipping.
-
wrote on 30 Jul 2013, 15:11 last edited by
[quote author="clogwog" date="1375195696"]when you say you tried to make the icons the same size, are they the same size ?
you could try
@onButton->setMaximumSize(toolBarButtonSize);
runButton->setMaximumSize(toolBarButtonSize);@but if the images aren't the same size you might get some clipping.[/quote]
The icons are the same size, but I guess because the images are different sizes, when you scroll over them the highlighted region just shows the image size. I want to stretch this to be the entire button size without changing the image size.
-
wrote on 30 Jul 2013, 15:50 last edited by
clogwog put me in the right direction. I solved it using:
@ onButton->setMinimumSize(toolBarButtonSize);
runButton->setMinimumSize(toolBarButtonSize);@Thanks!
1/4