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. Is it possible to draw a colored rectangle on a toolButton?
Forum Updated to NodeBB v4.3 + New Features

Is it possible to draw a colored rectangle on a toolButton?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 393 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.
  • Y Offline
    Y Offline
    Yue JIN
    wrote on last edited by
    #1

    I‘ve learned from this topic about how to draw a rectangle on a pushButton:
    https://forum.qt.io/topic/80901/is-it-possible-to-draw-a-colored-rectangle-on-a-pushbutton/2

    What about a toolbutton?
    I want to add a toolbutton which can change font color(like the button in MS office shown in picture).
    QQ浏览器截图20200228135938.png
    After choosing a color from the QColorDialog, put a rectangle on the toolButton and keep the icon.

    Furthermore, can I put a transparent icon in front of the rectangle?

    jsulmJ 1 Reply Last reply
    0
    • Y Yue JIN

      I‘ve learned from this topic about how to draw a rectangle on a pushButton:
      https://forum.qt.io/topic/80901/is-it-possible-to-draw-a-colored-rectangle-on-a-pushbutton/2

      What about a toolbutton?
      I want to add a toolbutton which can change font color(like the button in MS office shown in picture).
      QQ浏览器截图20200228135938.png
      After choosing a color from the QColorDialog, put a rectangle on the toolButton and keep the icon.

      Furthermore, can I put a transparent icon in front of the rectangle?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Yue-JIN You can do the same with tool button: subclass QToolButton and override paintEvent.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      Y 1 Reply Last reply
      3
      • jsulmJ jsulm

        @Yue-JIN You can do the same with tool button: subclass QToolButton and override paintEvent.

        Y Offline
        Y Offline
        Yue JIN
        wrote on last edited by
        #3

        @jsulm So I need to add custom tool button to tool bar in code instead of adding action in qt designer?

        jsulmJ 1 Reply Last reply
        0
        • Y Yue JIN

          @jsulm So I need to add custom tool button to tool bar in code instead of adding action in qt designer?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Yue-JIN Yes, with your QToolButton subclass you have to

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          2

          • Login

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