Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. How to integrate a cursor in a QtWidgets app
Forum Updated to NodeBB v4.3 + New Features

How to integrate a cursor in a QtWidgets app

Scheduled Pinned Locked Moved Solved Qt for Python
23 Posts 4 Posters 3.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.
  • P Pianissimo89

    @JonB thanks again for the tips. i think i solved the problem by creating a dedicated class

    class my_canvas(scene.SceneCanvas):
        def __init__(self):
            super().__init__(keys="interactive")
    
        def on_mouse_press(self, event):
            print("hello")
    
    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #21

    @Pianissimo89 said in How to integrate a cursor in a QtWidgets app:

    on_mouse_press

    mousePressEvent

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

    JonBJ 1 Reply Last reply
    0
    • jsulmJ jsulm

      @Pianissimo89 said in How to integrate a cursor in a QtWidgets app:

      on_mouse_press

      mousePressEvent

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #22

      @jsulm
      I believe you are mistaking the issue! :) The OP says this code works as-is. He puts this code in a class derived from scene.SceneCanvas, which is some OpenGL class, not Qt. I believe the mouse events are being handled inside that, not Qt, so if that wants a on_mouse_press() method so be it.

      Correct me if I am wrong. Of course if that code does not actually work as the OP implies then it's a different matter!

      P 1 Reply Last reply
      1
      • JonBJ JonB

        @jsulm
        I believe you are mistaking the issue! :) The OP says this code works as-is. He puts this code in a class derived from scene.SceneCanvas, which is some OpenGL class, not Qt. I believe the mouse events are being handled inside that, not Qt, so if that wants a on_mouse_press() method so be it.

        Correct me if I am wrong. Of course if that code does not actually work as the OP implies then it's a different matter!

        P Offline
        P Offline
        Pianissimo89
        wrote on last edited by Pianissimo89
        #23

        @JonB you understood me right. i have to follow this code because it is going to be integrated in another code where I need it to be OpenGL.
        and yes i confirm what you say about the mouse events. seems that inside the opengl canvas we need dedicated mouse events . outside of the windows is Qt where mousePressEvent works. these are two different frameworks.

        I thank all the contributors for helping me. As I am new to QtWidgets.

        now i am trying to move the cursor i created. I set now the question as resolved as it does not involve Qt anymore

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved