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. Graphics Effects
Qt 6.11 is out! See what's new in the release blog

Graphics Effects

Scheduled Pinned Locked Moved General and Desktop
5 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.
  • N Offline
    N Offline
    Noobie
    wrote on last edited by
    #1

    Hi
    I am new to Qt and have started playing with graphics effect and cannot quite achieve what I want.
    I have a an object of type QWidget that has a QButton as a child.
    I want to apply a different effect to the QWidget and the button -

    m_effect1 = new QGraphicsOpacityEffect();
    m_effect2 = new QGraphicsOpacityEffect();
    
    m_effect1->setOpacity(1.0);
    m_effect2->setOpacity(1.0);
    
    ui.pushButton->setGraphicsEffect(m_effect2);
    ui.stackedWidget->setGraphicsEffect(m_effect1);
    

    When I run the Qt complains the a paint device can only be painted by one painter at a time

    Could anyone be kind enough to help me?

    Thanks

    Bob

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      this is not working when the 2 widgets are in parent-child relationship.

      You can only achieve this when the 2 widgets have the same parent and you stack them above each other.

      So if you depend on the parent-child relationship and can't break up your widgets this won't be possible.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • N Offline
        N Offline
        Noobie
        wrote on last edited by
        #3

        Hi
        Thanks for your reply
        What do you mean by

        You can only achieve this when the 2 widgets have the same parent and you stack them above each other.

        Thanks

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          they both have the same parent and for example set the z-order (stacking) to make it look like the one is a child of the other.
          You would ensure to layout the items by yourself though on every resize of the common parent.

          For z-order changing you can use QWidget methods: raise(), lower(), stackUnder()

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • N Offline
            N Offline
            Noobie
            wrote on last edited by
            #5

            Ok
            Looks like I cant achieve what I need

            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