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. Applying the color of Custom widgets to the controls inside it
Forum Updated to NodeBB v4.3 + New Features

Applying the color of Custom widgets to the controls inside it

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 165 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.
  • T Offline
    T Offline
    thomasjohnaj
    wrote on last edited by
    #1

    I have created a custom widget derived from QWidget.

    1. it contain 2 buttons and on label.

    2. I am applying the background color to the QWidget using the

       QStylePainter painter(this);
      

      painter.fillRect(rect(), QColor(255,255,255);

    when I do this , the color is filled on the rectangular area of the custom widget and also to the label inside it.

    For the buttons it is not applied. What is the reason for this and what is the potential solution.

    Second issue I am facing , is the button is not appearing as a if it is not integrated to the custom control. it is projected out. If you see the below image the button is not flat and integrated with the parent control. So how to achieve this also?

    3cabc877-a606-4401-88e6-292a6db3a44d-image.png

    I tried stylesheet, it resolved both the issues. But I am looking for alternate for stylesheet

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi

      -For the buttons, it is not applied. What is the reason for this and what is the potential solution?

      Hi, the labels are transparent (no background color) so you see your custom widget through them.
      Buttons do have a background normally.

      You could use ToolButtons and set auto raise
      alt text

      which allows seeing through the button.

      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