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. Use uic.loadUi and get mouseMoveEvent

Use uic.loadUi and get mouseMoveEvent

Scheduled Pinned Locked Moved Solved Qt for Python
15 Posts 3 Posters 2.4k 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.
  • M Offline
    M Offline
    Mikeeeeee
    wrote on last edited by
    #1

    Hi!
    I use

    class MainWindow(QMainWindow): 
        def __init__(self): 
            super(MainWindow, self).__init__()
            self.ui = uic.loadUi("mainWindow.ui")
    

    How I can get mouseMoveEvent from "mainWindow.ui"?

    JonBJ 1 Reply Last reply
    0
    • M Mikeeeeee

      Hi!
      I use

      class MainWindow(QMainWindow): 
          def __init__(self): 
              super(MainWindow, self).__init__()
              self.ui = uic.loadUi("mainWindow.ui")
      

      How I can get mouseMoveEvent from "mainWindow.ui"?

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

      @Mikeeeeee
      Override mouseMoveEvent(). Or install an event filter via installEventFilter().

      M 1 Reply Last reply
      1
      • JonBJ JonB

        @Mikeeeeee
        Override mouseMoveEvent(). Or install an event filter via installEventFilter().

        M Offline
        M Offline
        Mikeeeeee
        wrote on last edited by
        #3

        @JonB said in Use uic.loadUi and get mouseMoveEvent:

        Or install an event filter via installEventFilter().

        Please give an example of how to do this

        jsulmJ 1 Reply Last reply
        0
        • M Mikeeeeee

          @JonB said in Use uic.loadUi and get mouseMoveEvent:

          Or install an event filter via installEventFilter().

          Please give an example of how to do this

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Mikeeeeee There are enough examples in Qt documentation.
          https://doc.qt.io/qt-5/qtwidgets-widgets-scribble-example.html

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

          M 1 Reply Last reply
          3
          • jsulmJ jsulm

            @Mikeeeeee There are enough examples in Qt documentation.
            https://doc.qt.io/qt-5/qtwidgets-widgets-scribble-example.html

            M Offline
            M Offline
            Mikeeeeee
            wrote on last edited by
            #5

            @jsulm said in Use uic.loadUi and get mouseMoveEvent:

            There are enough examples in Qt documentation.
            https://doc.qt.io/qt-5/qtwidgets-widgets-scribble-example.html

            There is no installEventFilter in this example

            jsulmJ 1 Reply Last reply
            0
            • M Mikeeeeee

              @jsulm said in Use uic.loadUi and get mouseMoveEvent:

              There are enough examples in Qt documentation.
              https://doc.qt.io/qt-5/qtwidgets-widgets-scribble-example.html

              There is no installEventFilter in this example

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Mikeeeeee There is example for mouseMoveEvent
              But I again did the search for you (no idea why you can't): https://doc.qt.io/qt-5/qobject.html#installEventFilter

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

              M 1 Reply Last reply
              2
              • jsulmJ jsulm

                @Mikeeeeee There is example for mouseMoveEvent
                But I again did the search for you (no idea why you can't): https://doc.qt.io/qt-5/qobject.html#installEventFilter

                M Offline
                M Offline
                Mikeeeeee
                wrote on last edited by
                #7

                @jsulm said in Use uic.loadUi and get mouseMoveEvent:

                There is example for mouseMoveEvent
                But I again did the search for you (no idea why you can't): https://doc.qt.io/qt-5/qobject.html#installEventFilter

                I saw it.
                It is not work:

                self.installEventFilter(self.ui)
                
                
                    def eventFilter(self, object, event):
                        print(111111111111111)
                
                jsulmJ 1 Reply Last reply
                0
                • M Mikeeeeee

                  @jsulm said in Use uic.loadUi and get mouseMoveEvent:

                  There is example for mouseMoveEvent
                  But I again did the search for you (no idea why you can't): https://doc.qt.io/qt-5/qobject.html#installEventFilter

                  I saw it.
                  It is not work:

                  self.installEventFilter(self.ui)
                  
                  
                      def eventFilter(self, object, event):
                          print(111111111111111)
                  
                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @Mikeeeeee said in Use uic.loadUi and get mouseMoveEvent:

                  self.ui

                  this is not an event filter...

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

                  1 Reply Last reply
                  1
                  • M Offline
                    M Offline
                    Mikeeeeee
                    wrote on last edited by
                    #9

                    How do I get the events from the self.ui?

                    jsulmJ 1 Reply Last reply
                    0
                    • M Mikeeeeee

                      How do I get the events from the self.ui?

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @Mikeeeeee Install event filter there, probably like (I don't use Qt with Python):

                      self.ui.installEventFilter(myEventFilter)
                      

                      where myEventFilter is your event filter object (like keyPressEater in the example).

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

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        Mikeeeeee
                        wrote on last edited by
                        #11

                        @jsulm said in Use uic.loadUi and get mouseMoveEvent:

                        lf.ui.installEventFilter(myEventFilter)

                        Documentation:
                        void QObject::installEventFilter(QObject *filterObj)
                        Installs an event filter filterObj on this object. For example:

                        monitoredObj->installEventFilter(filterObj);
                        

                        Your code will not work, you need to put an object in the function argument. I still need an example.

                        jsulmJ 1 Reply Last reply
                        0
                        • M Mikeeeeee

                          @jsulm said in Use uic.loadUi and get mouseMoveEvent:

                          lf.ui.installEventFilter(myEventFilter)

                          Documentation:
                          void QObject::installEventFilter(QObject *filterObj)
                          Installs an event filter filterObj on this object. For example:

                          monitoredObj->installEventFilter(filterObj);
                          

                          Your code will not work, you need to put an object in the function argument. I still need an example.

                          jsulmJ Offline
                          jsulmJ Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          @Mikeeeeee said in Use uic.loadUi and get mouseMoveEvent:

                          our code will not work, you need to put an object in the function argument.

                          That's exactly what I'm doing:

                          self.ui.installEventFilter(myEventFilter)
                          

                          I even wrote: "where myEventFilter is your event filter object"!
                          So, why do you think it will not work? Did you try? I have no idea what other example you need, I'm out of this thread...

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

                          1 Reply Last reply
                          0
                          • M Offline
                            M Offline
                            Mikeeeeee
                            wrote on last edited by
                            #13

                            @jsulm said in Use uic.loadUi and get mouseMoveEvent:

                            myEventFilter

                            I don't understand you. Please give a full-fledged example.

                            jsulmJ 1 Reply Last reply
                            0
                            • M Offline
                              M Offline
                              Mikeeeeee
                              wrote on last edited by
                              #14

                              It is work

                              self.ui.installEventFilter(self)
                              
                              1 Reply Last reply
                              0
                              • M Mikeeeeee

                                @jsulm said in Use uic.loadUi and get mouseMoveEvent:

                                myEventFilter

                                I don't understand you. Please give a full-fledged example.

                                jsulmJ Offline
                                jsulmJ Offline
                                jsulm
                                Lifetime Qt Champion
                                wrote on last edited by
                                #15

                                @Mikeeeeee said in Use uic.loadUi and get mouseMoveEvent:

                                Please give a full-fledged example.

                                I will not.

                                class MyEventFilter(QObject):
                                    def eventFilter(QObject obj, QEvent event):
                                        print("HERE")
                                        return QObject::eventFilter(obj, event)
                                ...
                                
                                myEventFilter = MyEventFilter()
                                self.ui.installEventFilter(myEventFilter)
                                

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

                                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