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. Qt::WA_PaintOnScreen and WA_NativeWindow problem
Forum Updated to NodeBB v4.3 + New Features

Qt::WA_PaintOnScreen and WA_NativeWindow problem

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 2 Posters 7.1k 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.
  • A Offline
    A Offline
    Alatriste
    wrote on last edited by
    #1

    I'm creating QWidget and setting

     setAttribute(Qt::WA_PaintOnScreen, true);
     setAttribute(Qt::WA_NativeWindow, true);
    

    for GPU rendering , and I'm returning nullptr into paintEngine() const;
    But sometimes I need to disable them by:

      setAttribute(Qt::WA_PaintOnScreen, false);
      setAttribute(Qt::WA_NativeWindow, false);
    

    and returning QWidget::paintengine() into paintEngine() const, instead of nullptr.
    but Qt is not drawing anything.

    kshegunovK 1 Reply Last reply
    0
    • A Alatriste

      I'm creating QWidget and setting

       setAttribute(Qt::WA_PaintOnScreen, true);
       setAttribute(Qt::WA_NativeWindow, true);
      

      for GPU rendering , and I'm returning nullptr into paintEngine() const;
      But sometimes I need to disable them by:

        setAttribute(Qt::WA_PaintOnScreen, false);
        setAttribute(Qt::WA_NativeWindow, false);
      

      and returning QWidget::paintengine() into paintEngine() const, instead of nullptr.
      but Qt is not drawing anything.

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      @Alatriste
      Hello,
      Once your widget is native (meaning it has an OS specific handle attached to it) there is not turning back. The only way to make it non-native again is to destroy and create it anew. I don't know about the paint on screen attribute, but I'm pretty sure QWidget::paintEngine() works in a similar fashion. In the end, why would you need to do these things anyway?

      Read and abide by the Qt Code of Conduct

      A 1 Reply Last reply
      0
      • kshegunovK kshegunov

        @Alatriste
        Hello,
        Once your widget is native (meaning it has an OS specific handle attached to it) there is not turning back. The only way to make it non-native again is to destroy and create it anew. I don't know about the paint on screen attribute, but I'm pretty sure QWidget::paintEngine() works in a similar fashion. In the end, why would you need to do these things anyway?

        A Offline
        A Offline
        Alatriste
        wrote on last edited by
        #3

        @kshegunov Thank you for this information. It's bad that I must recreate a widget. I need this switching for some test.

        kshegunovK 1 Reply Last reply
        0
        • A Alatriste

          @kshegunov Thank you for this information. It's bad that I must recreate a widget. I need this switching for some test.

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #4

          @Alatriste
          Maybe if you describe your use case, I might be able to suggest some alternative. What is exactly that you're trying to achieve?

          Read and abide by the Qt Code of Conduct

          A 1 Reply Last reply
          0
          • kshegunovK kshegunov

            @Alatriste
            Maybe if you describe your use case, I might be able to suggest some alternative. What is exactly that you're trying to achieve?

            A Offline
            A Offline
            Alatriste
            wrote on last edited by
            #5

            @kshegunov I'm trying to render into this widget by DirectX and disabling all qt draws, but after some time I want to enable Qt draws and disable DirectX rendering. Is this information enought?

            kshegunovK 1 Reply Last reply
            0
            • A Alatriste

              @kshegunov I'm trying to render into this widget by DirectX and disabling all qt draws, but after some time I want to enable Qt draws and disable DirectX rendering. Is this information enought?

              kshegunovK Offline
              kshegunovK Offline
              kshegunov
              Moderators
              wrote on last edited by
              #6

              @Alatriste
              I got that from your original question, my wondering was more to the why. Anyway. The most simple thing I can suggest is to put your DX and your Qt-drawn widget into a QStackedWidget and when you need to just switch the pages. Is this something that works for you?

              Kind regards,

              Read and abide by the Qt Code of Conduct

              A 1 Reply Last reply
              0
              • kshegunovK kshegunov

                @Alatriste
                I got that from your original question, my wondering was more to the why. Anyway. The most simple thing I can suggest is to put your DX and your Qt-drawn widget into a QStackedWidget and when you need to just switch the pages. Is this something that works for you?

                Kind regards,

                A Offline
                A Offline
                Alatriste
                wrote on last edited by
                #7

                @kshegunov Good idea but that dont works for me.. So the only way to do this, recreating widget. thanks .

                kshegunovK 1 Reply Last reply
                0
                • A Alatriste

                  @kshegunov Good idea but that dont works for me.. So the only way to do this, recreating widget. thanks .

                  kshegunovK Offline
                  kshegunovK Offline
                  kshegunov
                  Moderators
                  wrote on last edited by
                  #8

                  @Alatriste
                  At least the only one I know of. I guess there is even the possibility to not use stacked widget at all, but have two toplevel widgets and switch them by hand, but this is pretty much what the stack widget does ...

                  Read and abide by the Qt Code of Conduct

                  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