Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. how to execute a QCombobox Pyqt6 cursor output method
Forum Update on Monday, May 27th 2025

how to execute a QCombobox Pyqt6 cursor output method

Scheduled Pinned Locked Moved Unsolved Qt 6
lost cursorqcomboboxpyqt6
16 Posts 4 Posters 2.1k 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.
  • J Offline
    J Offline
    Jbone73
    wrote on 24 Feb 2022, 07:53 last edited by
    #5

    Hello everybody,

    I'm sorry for my delay, I tested jsulm's post and followed the instructions. It works but I have a little presentation problem. The combobox cursor does not delete itself and I end up with another cursor on the other fields.

    My code :

    class MainWindow(QMainWindow):
        def __init__(self):
            super().__init__()
            
            frame = QtWidgets.QFrame(self)
            qc == ComboBox(frame)
            qc.focusOutEvent()
    
    class ComboBox(QComboBox):
    
        def focusOutEvent(self, event=QFocusEvent):
            pass
    

    Do you have any idea about this problem?

    Thank you in advance.

    J 1 Reply Last reply 24 Feb 2022, 10:23
    0
    • J Jbone73
      24 Feb 2022, 07:53

      Hello everybody,

      I'm sorry for my delay, I tested jsulm's post and followed the instructions. It works but I have a little presentation problem. The combobox cursor does not delete itself and I end up with another cursor on the other fields.

      My code :

      class MainWindow(QMainWindow):
          def __init__(self):
              super().__init__()
              
              frame = QtWidgets.QFrame(self)
              qc == ComboBox(frame)
              qc.focusOutEvent()
      
      class ComboBox(QComboBox):
      
          def focusOutEvent(self, event=QFocusEvent):
              pass
      

      Do you have any idea about this problem?

      Thank you in advance.

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 24 Feb 2022, 10:23 last edited by
      #6

      @Jbone73 said in how to execute a QCombobox Pyqt6 cursor output method:

      Do you have any idea about this problem?

      Yes, you should also call the base class focusOutEvent in your focusOutEvent implementation.

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

      J 1 Reply Last reply 24 Feb 2022, 10:37
      1
      • J jsulm
        24 Feb 2022, 10:23

        @Jbone73 said in how to execute a QCombobox Pyqt6 cursor output method:

        Do you have any idea about this problem?

        Yes, you should also call the base class focusOutEvent in your focusOutEvent implementation.

        J Offline
        J Offline
        Jbone73
        wrote on 24 Feb 2022, 10:37 last edited by
        #7

        @jsulm

        Agreed ! Thank you ! I'm new to Qt and Python, I must admit I had a hard time understanding what you're asking to do.

        Do I have to call the QFocusEvent class in the QCombobox class?

        I'm sorry to ask so many questions but this is really new to me.

        Thank you in advance.

        J 1 Reply Last reply 24 Feb 2022, 10:39
        0
        • J Jbone73
          24 Feb 2022, 10:37

          @jsulm

          Agreed ! Thank you ! I'm new to Qt and Python, I must admit I had a hard time understanding what you're asking to do.

          Do I have to call the QFocusEvent class in the QCombobox class?

          I'm sorry to ask so many questions but this is really new to me.

          Thank you in advance.

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 24 Feb 2022, 10:39 last edited by
          #8

          @Jbone73

          class ComboBox(QComboBox):
              def focusOutEvent(self, event=QFocusEvent):
                  super().focusOutEvent(event)
          

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

          J 1 Reply Last reply 24 Feb 2022, 10:52
          0
          • J jsulm
            24 Feb 2022, 10:39

            @Jbone73

            class ComboBox(QComboBox):
                def focusOutEvent(self, event=QFocusEvent):
                    super().focusOutEvent(event)
            
            J Offline
            J Offline
            Jbone73
            wrote on 24 Feb 2022, 10:52 last edited by
            #9

            @jsulm
            Thank you (sorry! I keep telling you but help is always useful, especially when you're just starting out), so I tried but I have a problem with the focusOutEvent method, which I can't seem to figure out the meaning of or event = QFocusEvent.

            The error is:
            TypeError: focusOutEvent(self, QFocusEvent): argument 1 has unexpected type 'PyQt6.sip.wrappertype'

            Thank you for everything and if you don't mind and if it's not too long, would you be able to explain to me? I admit that I swim a little.

            J 1 Reply Last reply 24 Feb 2022, 11:03
            0
            • J Jbone73
              24 Feb 2022, 10:52

              @jsulm
              Thank you (sorry! I keep telling you but help is always useful, especially when you're just starting out), so I tried but I have a problem with the focusOutEvent method, which I can't seem to figure out the meaning of or event = QFocusEvent.

              The error is:
              TypeError: focusOutEvent(self, QFocusEvent): argument 1 has unexpected type 'PyQt6.sip.wrappertype'

              Thank you for everything and if you don't mind and if it's not too long, would you be able to explain to me? I admit that I swim a little.

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 24 Feb 2022, 11:03 last edited by
              #10

              @Jbone73 Please show the code causing this error

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

              J 1 Reply Last reply 24 Feb 2022, 11:09
              0
              • J jsulm
                24 Feb 2022, 11:03

                @Jbone73 Please show the code causing this error

                J Offline
                J Offline
                Jbone73
                wrote on 24 Feb 2022, 11:09 last edited by
                #11

                @jsulm
                This is the one you shared with me, I note it below:

                class ComboBox(QComboBox):
                    def focusOutEvent(self, event=QFocusEvent):
                        super().focusOutEvent(event)
                
                J S 2 Replies Last reply 24 Feb 2022, 11:46
                0
                • J Jbone73
                  24 Feb 2022, 11:09

                  @jsulm
                  This is the one you shared with me, I note it below:

                  class ComboBox(QComboBox):
                      def focusOutEvent(self, event=QFocusEvent):
                          super().focusOutEvent(event)
                  
                  J Offline
                  J Offline
                  JonB
                  wrote on 24 Feb 2022, 11:46 last edited by
                  #12

                  @Jbone73
                  Only a guess, depends what you have imported how, QFocusEvent might not be defined, you might need QtGui.QFocusEvent.

                  J 1 Reply Last reply 24 Feb 2022, 12:07
                  0
                  • J JonB
                    24 Feb 2022, 11:46

                    @Jbone73
                    Only a guess, depends what you have imported how, QFocusEvent might not be defined, you might need QtGui.QFocusEvent.

                    J Offline
                    J Offline
                    Jbone73
                    wrote on 24 Feb 2022, 12:07 last edited by
                    #13

                    @JonB

                    Hello JonB, thank you for your answer.

                    I just looked and QFocusEvent is present in QtGui.

                    I don't see why he is marking this message for me.

                    from PyQt6.QtGui import QIcon, QPixmap, QIntValidator, QFocusEvent
                    
                    1 Reply Last reply
                    0
                    • J Jbone73
                      24 Feb 2022, 11:09

                      @jsulm
                      This is the one you shared with me, I note it below:

                      class ComboBox(QComboBox):
                          def focusOutEvent(self, event=QFocusEvent):
                              super().focusOutEvent(event)
                      
                      S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 24 Feb 2022, 20:17 last edited by
                      #14

                      Hi,

                      @Jbone73 said in how to execute a QCombobox Pyqt6 cursor output method:

                      @jsulm
                      This is the one you shared with me, I note it below:

                      class ComboBox(QComboBox):
                          def focusOutEvent(self, event=QFocusEvent):
                              super().focusOutEvent(event)
                      

                      What about ?

                      class ComboBox(QComboBox):
                           def focusOutEvent(self, event):
                               super().focusOutEvent(event)
                      

                      If you want type hints:

                      class ComboBox(QComboBox):
                           def focusOutEvent(self, event: QFocusEvent) -> None:
                               super().focusOutEvent(event)
                      

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

                      J 1 Reply Last reply 25 Feb 2022, 10:30
                      0
                      • S SGaist
                        24 Feb 2022, 20:17

                        Hi,

                        @Jbone73 said in how to execute a QCombobox Pyqt6 cursor output method:

                        @jsulm
                        This is the one you shared with me, I note it below:

                        class ComboBox(QComboBox):
                            def focusOutEvent(self, event=QFocusEvent):
                                super().focusOutEvent(event)
                        

                        What about ?

                        class ComboBox(QComboBox):
                             def focusOutEvent(self, event):
                                 super().focusOutEvent(event)
                        

                        If you want type hints:

                        class ComboBox(QComboBox):
                             def focusOutEvent(self, event: QFocusEvent) -> None:
                                 super().focusOutEvent(event)
                        
                        J Offline
                        J Offline
                        Jbone73
                        wrote on 25 Feb 2022, 10:30 last edited by
                        #15

                        @SGaist
                        Hello !
                        I don't understand ??

                        If I use your code :

                        class ComboBox(QComboBox):
                             def focusOutEvent(self, event: QFocusEvent) -> None:
                                 super().focusOutEvent(event)
                        

                        Or

                        class ComboBox(QComboBox):
                             def focusOutEvent(self, event):
                                 super().focusOutEvent(event)
                        

                        I have messages of errors and it does not work, on the other hand, if I put:

                        class ComboBox(QComboBox):
                        
                            def focusOutEvent(self, event=QFocusEvent):
                                print('ok')
                        

                        I do not have problem anymore, it works but not correctly.
                        The cursor of the combobox remains active when it takes the focus and I meet with another focus on other Widgets.

                        I do not understand why this does not work correctly???

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 25 Feb 2022, 20:14 last edited by
                          #16

                          Can you provide a minimal complete script to reproduce this behaviour ?

                          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

                          14/16

                          24 Feb 2022, 20:17

                          • Login

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