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. Is calling requestUpdate() in QEvent::UpdateRequest valid?
Forum Updated to NodeBB v4.3 + New Features

Is calling requestUpdate() in QEvent::UpdateRequest valid?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 1.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.
  • P Offline
    P Offline
    PsyX
    wrote on last edited by PsyX
    #1

    Hey there,
    I want to render with Vulkan to my Qt surface. From the examples and the existing code I've figured to call requestUpdate() inside of an UpdateRequest event callback, to enforce continuous rendering.

    Can someone tell me if this is the correct approach?

    (I want to subclass directly from QWindow and not use QVulkanWindow)

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

      Hi and welcome to devnet,

      What example are you talking about ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • P Offline
        P Offline
        PsyX
        wrote on last edited by
        #3

        Hello SGaist, thanks!

        Example is actually the wrong word, I looked into the source files of the QVulkanWindow class:
        https://code.woboq.org/qt5/qtbase/src/gui/vulkan/qvulkanwindow.cpp.html

        My primary goal is to render with Vulkan on a surface provided by Qt.
        I know that QVulkanWindow exists, but it already provides a SwapChain(etc.) which I prefer to create myself. So in the details description of QVulkanWindow it says:

        Note: QVulkanWindow does not always eliminate the need to implement a fully custom QWindow subclass as it will not necessarily be sufficient in advanced use cases.

        I want to make use of Qts platform independency while doing the Vulkan stuff myself. So I wonder if calling requestUpdate() out of a callback from QEvent::UpdateRequest is the right approach.

        bool event(QEvent* event) override
        {
            switch (event->type()) 
            {
            case QEvent::UpdateRequest:
                renderNow();
                return true;
            default:
                return QWindow::event(event);
            }
        }
        
        void renderNow()
        {
            // ... render code
            requestUpdate();
        }
        

        Thanks for bothering.

        1 Reply Last reply
        0
        • P Offline
          P Offline
          PsyX
          wrote on last edited by
          #4

          So after more research, I finally found the solution to what I was looking for myself:
          https://doc.qt.io/qt-5/qvulkaninstance.html#example

          I wonder how I could have missed that, during my hour long researches... probably because I didn't knew what exactly I was looking for.

          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