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. [SOLVED] Make all toolbar buttons same clickable size
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Make all toolbar buttons same clickable size

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.2k 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.
  • R Offline
    R Offline
    rizoritis
    wrote on 30 Jul 2013, 13:32 last edited by
    #1

    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!

    1 Reply Last reply
    0
    • C Offline
      C Offline
      clogwog
      wrote on 30 Jul 2013, 14:48 last edited by
      #2

      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.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rizoritis
        wrote on 30 Jul 2013, 15:11 last edited by
        #3

        [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.

        1 Reply Last reply
        0
        • R Offline
          R Offline
          rizoritis
          wrote on 30 Jul 2013, 15:50 last edited by
          #4

          clogwog put me in the right direction. I solved it using:

          @ onButton->setMinimumSize(toolBarButtonSize);
          runButton->setMinimumSize(toolBarButtonSize);@

          Thanks!

          1 Reply Last reply
          0

          1/4

          30 Jul 2013, 13:32

          • Login

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