Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Mouse events in QML rendered using QQuickRenderControl
Forum Updated to NodeBB v4.3 + New Features

Mouse events in QML rendered using QQuickRenderControl

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 333 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.
  • L Offline
    L Offline
    LoneWolf10
    wrote on last edited by
    #1

    Greetings,
    I have tried to implement QML rendering into QOffscreenSurface and using this as a texture in OpenGL (same as example provided by Qt). I am also trying to implement mouse events so that if a user clicks on the QML interface it will respond (I have tried the QML with ToggleButton and some buttons that change the text color in a Text). I am using

    void UIRenderer::mousePress(double x,double y)
    {
        QPointF pos(x*WINDOW_WIDTH,y*WINDOW_HEIGHT);
        QMouseEvent mappedEvent(QEvent::MouseButtonPress, pos, Qt::MouseButton::LeftButton, Qt::MouseButton::LeftButton, Qt::NoModifier);
        QCoreApplication::sendEvent(m_quickWindow, &mappedEvent);
    }
    
    void UIRenderer::mouseRelease(double x,double y)
    {
        QPointF pos(x*WINDOW_WIDTH,y*WINDOW_HEIGHT);
        QMouseEvent mappedEvent(QEvent::MouseButtonRelease, pos, Qt::MouseButton::LeftButton, Qt::MouseButton::LeftButton, Qt::NoModifier);
        QCoreApplication::sendEvent(m_quickWindow, &mappedEvent);
    }
    

    where x = [0..1] and y = [0..1] represent mouse event location. The problem is that when I click on some button and then I click on some other buttons the first clicked button responds (regardles of where the click event occured). I am certain that I missed something. Could you please help?

    Thank you.

    DiracsbracketD 1 Reply Last reply
    0
    • L LoneWolf10

      Greetings,
      I have tried to implement QML rendering into QOffscreenSurface and using this as a texture in OpenGL (same as example provided by Qt). I am also trying to implement mouse events so that if a user clicks on the QML interface it will respond (I have tried the QML with ToggleButton and some buttons that change the text color in a Text). I am using

      void UIRenderer::mousePress(double x,double y)
      {
          QPointF pos(x*WINDOW_WIDTH,y*WINDOW_HEIGHT);
          QMouseEvent mappedEvent(QEvent::MouseButtonPress, pos, Qt::MouseButton::LeftButton, Qt::MouseButton::LeftButton, Qt::NoModifier);
          QCoreApplication::sendEvent(m_quickWindow, &mappedEvent);
      }
      
      void UIRenderer::mouseRelease(double x,double y)
      {
          QPointF pos(x*WINDOW_WIDTH,y*WINDOW_HEIGHT);
          QMouseEvent mappedEvent(QEvent::MouseButtonRelease, pos, Qt::MouseButton::LeftButton, Qt::MouseButton::LeftButton, Qt::NoModifier);
          QCoreApplication::sendEvent(m_quickWindow, &mappedEvent);
      }
      

      where x = [0..1] and y = [0..1] represent mouse event location. The problem is that when I click on some button and then I click on some other buttons the first clicked button responds (regardles of where the click event occured). I am certain that I missed something. Could you please help?

      Thank you.

      DiracsbracketD Offline
      DiracsbracketD Offline
      Diracsbracket
      wrote on last edited by
      #2

      @LoneWolf10
      Could you post some minimal working example for others to test out?

      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