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. How to prevent child widgets from rendering outside the bounds of their parent widget?
Forum Updated to NodeBB v4.3 + New Features

How to prevent child widgets from rendering outside the bounds of their parent widget?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 360 Views
  • 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.
  • M Offline
    M Offline
    Mizmas
    wrote on last edited by Mizmas
    #1

    Hi, I have a window with a windowless flag that I'm using as a splash screen.

    I'm using a QFrame 'shadow_frame' for a shadow effect, and another QFrame that inherits from a QLabel to display gifs called 'main_frame'. They're both the same size.
    Screenshot_4.png

    If I set the 'main_frame' background to transparent, you can see the bounds of the shadow_frame

    QFrame#shadow_frame{
    	background-color: red;
    	border-radius: 30px;
    }
    QFrame#main_frame {
    	background-color: transparent;
    }
    

    Screenshot_5.png

    If I set the background color of the 'main_frame' to a solid color, it goes outside the bounds of 'shadow_frame'

    QFrame#shadow_frame{
    	background-color: red;
    	border-radius: 30px;
    }
    QFrame#main_frame {
    	background-color: green;
    }
    

    Screenshot_6.png

    jsulmJ 1 Reply Last reply
    0
    • M Mizmas

      Hi, I have a window with a windowless flag that I'm using as a splash screen.

      I'm using a QFrame 'shadow_frame' for a shadow effect, and another QFrame that inherits from a QLabel to display gifs called 'main_frame'. They're both the same size.
      Screenshot_4.png

      If I set the 'main_frame' background to transparent, you can see the bounds of the shadow_frame

      QFrame#shadow_frame{
      	background-color: red;
      	border-radius: 30px;
      }
      QFrame#main_frame {
      	background-color: transparent;
      }
      

      Screenshot_5.png

      If I set the background color of the 'main_frame' to a solid color, it goes outside the bounds of 'shadow_frame'

      QFrame#shadow_frame{
      	background-color: red;
      	border-radius: 30px;
      }
      QFrame#main_frame {
      	background-color: green;
      }
      

      Screenshot_6.png

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

      @Mizmas said in How to prevent child widgets from rendering outside the bounds of their parent widget?:

      They're both the same size

      This is the problem, not that the child is rendering outside of the parent (it does not).
      Make your main_frame smaller than its parent.

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

      M 1 Reply Last reply
      0
      • jsulmJ jsulm

        @Mizmas said in How to prevent child widgets from rendering outside the bounds of their parent widget?:

        They're both the same size

        This is the problem, not that the child is rendering outside of the parent (it does not).
        Make your main_frame smaller than its parent.

        M Offline
        M Offline
        Mizmas
        wrote on last edited by
        #3

        @jsulm They're the both the same size because one frame is used for the shadow effect only, and the other for displaying a gif that has a textured background, which is also the same size as both frames, obviously you can just round the corners of the gif, but I'm looking for more straightforward solution.
        In css there's a "overflow: hidden;" property, but in QT it doesn't work.

        M 1 Reply Last reply
        0
        • M Mizmas

          @jsulm They're the both the same size because one frame is used for the shadow effect only, and the other for displaying a gif that has a textured background, which is also the same size as both frames, obviously you can just round the corners of the gif, but I'm looking for more straightforward solution.
          In css there's a "overflow: hidden;" property, but in QT it doesn't work.

          M Offline
          M Offline
          Mizmas
          wrote on last edited by
          #4

          @Mizmas Here's the splash screen itself, I assumed that the parent widget should just cut everything off and round the corners based on its properties:
          https://imgur.com/a/GcLBb6t

          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