Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. 'Ui_MainWindow' object has no attribute
Forum Updated to NodeBB v4.3 + New Features

'Ui_MainWindow' object has no attribute

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 5.9k 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.
  • S Offline
    S Offline
    Steve Horton
    wrote on last edited by
    #1

    'Ui_MainWindow' object has no attribute 'lbl_Question_No_denary' is the error I keep getting I import UI code for a GUI made in QT Designer. The GUI has 3 tabs. the first tabs widgets are recognised, but the second is not?
    the code is below:
    class MainWindow_EXEC():

    def init(self):
    app = QtWidgets.QApplication(sys.argv)

    MainWindow = QtWidgets.QMainWindow()
    self.ui = Ui_MainWindow()
    self.ui.setupUi(MainWindow)
    
    # Binary Game instantiation
    self.ui.lbl_DenarytoBinary_Question_No.setText(str(1))
    self.ui.lbl_BinarytoDenary_currentScore.setText(str(0))
    self.ui.progressBar_BinarytoDenary.setValue(0)
    self.ui.lbl_BinarytoDenary_result.setText("")
    self.ui.lbl_BinarytoDenary_result_2.setText("")
    
    self.ui.spinBox_BinarytoDenary.setValue(0)
    self.createRandomBinaryNumber()
    self.ui.btn_BinarytoDenary_Answer.clicked.connect(self.getAnswerBinary)
    
    # Denary Game instantiation
    

    self.ui.lbl_Question_No_denary.setText(str(1))

    self.ui.lbl_random_number_denary.setText(str(00))
    self.ui.self.spinBox_16_denary.setValue(0)
    self.ui.self.spinBox_8_denary.setValue(0)
    self.ui.self.spinBox_4_denary.setValue(0)
    self.ui.self.spinBox_2_denary.setValue(0)
    self.ui.self.spinBox_1_denary.setValue(0)
    self.progressBar_denary.setValue(0)

    self.createRandomDenaryNumber()
    self.btn_Answer_denary.clicked.connect(self.getAnswerDenary)

    MainWindow.show()
    sys.exit(app.exec_())

    jsulmJ 1 Reply Last reply
    0
    • S Steve Horton

      'Ui_MainWindow' object has no attribute 'lbl_Question_No_denary' is the error I keep getting I import UI code for a GUI made in QT Designer. The GUI has 3 tabs. the first tabs widgets are recognised, but the second is not?
      the code is below:
      class MainWindow_EXEC():

      def init(self):
      app = QtWidgets.QApplication(sys.argv)

      MainWindow = QtWidgets.QMainWindow()
      self.ui = Ui_MainWindow()
      self.ui.setupUi(MainWindow)
      
      # Binary Game instantiation
      self.ui.lbl_DenarytoBinary_Question_No.setText(str(1))
      self.ui.lbl_BinarytoDenary_currentScore.setText(str(0))
      self.ui.progressBar_BinarytoDenary.setValue(0)
      self.ui.lbl_BinarytoDenary_result.setText("")
      self.ui.lbl_BinarytoDenary_result_2.setText("")
      
      self.ui.spinBox_BinarytoDenary.setValue(0)
      self.createRandomBinaryNumber()
      self.ui.btn_BinarytoDenary_Answer.clicked.connect(self.getAnswerBinary)
      
      # Denary Game instantiation
      

      self.ui.lbl_Question_No_denary.setText(str(1))

      self.ui.lbl_random_number_denary.setText(str(00))
      self.ui.self.spinBox_16_denary.setValue(0)
      self.ui.self.spinBox_8_denary.setValue(0)
      self.ui.self.spinBox_4_denary.setValue(0)
      self.ui.self.spinBox_2_denary.setValue(0)
      self.ui.self.spinBox_1_denary.setValue(0)
      self.progressBar_denary.setValue(0)

      self.createRandomDenaryNumber()
      self.btn_Answer_denary.clicked.connect(self.getAnswerDenary)

      MainWindow.show()
      sys.exit(app.exec_())

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

      @Steve-Horton said in 'Ui_MainWindow' object has no attribute:

      lbl_Question_No_denary

      Is the name really correct?

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

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Steve Horton
        wrote on last edited by
        #3

        yes, its. I have checked. It does not recognise any of the widgets from the second tab.

        mrjjM 1 Reply Last reply
        0
        • S Steve Horton

          yes, its. I have checked. It does not recognise any of the widgets from the second tab.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Steve-Horton
          Hi
          How do you import it ?
          as far as i understand one has to run pyuic5 on the ui file to generate ?

          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