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. Class issue in connect definition
Forum Updated to NodeBB v4.3 + New Features

Class issue in connect definition

Scheduled Pinned Locked Moved Solved Qt for Python
qt for python
12 Posts 3 Posters 927 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.
  • jsulmJ jsulm

    @heedaf said in Class issue in connect definition:

    self.pushButton.clicked.connect(Dialog.SB_UP_click)

    You're already connecting, so what does not work?

    And please indent your code properly: it is hard to read.

    H Offline
    H Offline
    heedaf
    wrote on last edited by
    #3

    @jsulm Sorry! On a cell phone and copied and pasted it over. When I try and write to the text of the label widget from this call I get something like label is not part of MainWindow.

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

      Hi,

      You do not have any widget named label_2 be it in your designer part or your MainWindow class.

      You have one that is named label that you can access through "self.ui".

      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
      1
      • H Offline
        H Offline
        heedaf
        wrote on last edited by
        #5

        My bad! Missed that on and just fixed it.. It should be just label. I'm using PyCharm so I copied it over from their forum. I'm not at my computer but I believe I got an error with self.ui.

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

          I see.

          You did the connection in the wrong class.
          Setup the connection in your MainWindow class not the one that is building the UI.

          Wrong code reading, it's really just the slot that has an error.

          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
          • H Offline
            H Offline
            heedaf
            wrote on last edited by heedaf
            #7
            This post is deleted!
            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #8

              No this one:

              @heedaf said in Class issue in connect definition:

              self.pushButton.clicked.connect(Dialog.SB_UP_click)

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

              H 1 Reply Last reply
              0
              • SGaistS SGaist

                No this one:

                @heedaf said in Class issue in connect definition:

                self.pushButton.clicked.connect(Dialog.SB_UP_click)

                H Offline
                H Offline
                heedaf
                wrote on last edited by
                #9

                @SGaist wow! I'm loosing it. That is the one I meant to paste. The ...connect... line is also created by PYUIC in pycharm.

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

                  Late night strikes again ! :-D
                  I misread the code.

                  Your slot should be something like:

                  def SB_UP_click(self):
                      print("SB UP")
                      self.ui.label.setText("HI")
                      print("got here")
                  

                  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
                  1
                  • H Offline
                    H Offline
                    heedaf
                    wrote on last edited by
                    #11

                    Well I'm seriously confused. I swear I tried what you suggested and it didn't work. But what you posted works and I would really like to know what I did wrong since it is an obvious solution. Thank you for your help.

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

                      You likely forgot the .ui between the self and .label.

                      Working with designer based UI requires some getting used to since you have all the code in the same file.

                      You have the Ui_XXX classes for the aesthetics of your widget (and which is auto generated) and the corresponding XXX that is for the logic you want to apply.

                      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
                      1

                      • Login

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