Problems with Open-Source Downloads read https://www.qt.io/blog/problem-with-open-source-downloads and https://forum.qt.io/post/638946

Applying the color of Custom widgets to the controls inside it



  • 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


  • Lifetime Qt Champion

    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.


Log in to reply