Results 1 to 4 of 4

Thread: A Widget is not updated

  1. #1
    Join Date
    Jul 2018
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Question A Widget is not updated

    I am having a hard time to find why the widget is not updated in my project.
    Because the project is too big to upload in this post, I made a simplified code.



    Qt Code:
    1. from PyQt5 import QtCore, QtGui, QtWidgets
    2. class Ui_Form(object):
    3. def setupUi(self, Form):
    4. Form.setObjectName("Form")
    5. Form.resize(191, 223)
    6. self.verticalLayoutWidget = QtWidgets.QWidget(Form)
    7. self.verticalLayoutWidget.setGeometry(QtCore.QRect(0, 170, 191, 21))
    8. self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
    9. self.verticalLayout = QtWidgets.QVBoxLayout(self.verticalLayoutWidget)
    10. self.verticalLayout.setContentsMargins(55, 0, 55, 0)
    11. self.verticalLayout.setObjectName("verticalLayout")
    12. self.saveButton = QtWidgets.QPushButton(self.verticalLayoutWidget)
    13. self.saveButton.setStyleSheet("background-color: rgb(200, 200, 200)")
    14. self.saveButton.setFlat(False)
    15. self.saveButton.setObjectName("saveButton")
    16. self.verticalLayout.addWidget(self.saveButton)
    17. self.layoutWidget = QtWidgets.QWidget(Form)
    18. self.layoutWidget.setGeometry(QtCore.QRect(0, 20, 191, 22))
    19. self.layoutWidget.setObjectName("layoutWidget")
    20. self.threadcountLayout = QtWidgets.QHBoxLayout(self.layoutWidget)
    21. self.threadcountLayout.setContentsMargins(5, 0, 0, 0)
    22. self.threadcountLayout.setObjectName("threadcountLayout")
    23. self.label = QtWidgets.QLabel(self.layoutWidget)
    24. sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
    25. sizePolicy.setHorizontalStretch(0)
    26. sizePolicy.setVerticalStretch(0)
    27. sizePolicy.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth())
    28. self.label.setSizePolicy(sizePolicy)
    29. self.label.setObjectName("label")
    30. self.threadcountLayout.addWidget(self.label)
    31. self.threadcountLineEdit = QtWidgets.QLineEdit(self.layoutWidget)
    32. sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
    33. sizePolicy.setHorizontalStretch(0)
    34. sizePolicy.setVerticalStretch(0)
    35. sizePolicy.setHeightForWidth(self.threadcountLineEdit.sizePolicy().hasHeightForWidth())
    36. self.threadcountLineEdit.setSizePolicy(sizePolicy)
    37. self.threadcountLineEdit.setMinimumSize(QtCore.QSize(25, 20))
    38. self.threadcountLineEdit.setMaximumSize(QtCore.QSize(1, 20))
    39. self.threadcountLineEdit.setMaxLength(3)
    40. self.threadcountLineEdit.setObjectName("threadcountLineEdit")
    41. self.threadcountLayout.addWidget(self.threadcountLineEdit)
    42. self.label_2 = QtWidgets.QLabel(self.layoutWidget)
    43. sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
    44. sizePolicy.setHorizontalStretch(0)
    45. sizePolicy.setVerticalStretch(0)
    46. sizePolicy.setHeightForWidth(self.label_2.sizePolicy().hasHeightForWidth())
    47. self.label_2.setSizePolicy(sizePolicy)
    48. self.label_2.setObjectName("label_2")
    49. self.threadcountLayout.addWidget(self.label_2)
    50. self.retranslateUi(Form)
    51. QtCore.QMetaObject.connectSlotsByName(Form)
    52.  
    53. def retranslateUi(self, Form):
    54. _translate = QtCore.QCoreApplication.translate
    55. Form.setWindowTitle(_translate("Form", "Form"))
    56. self.saveButton.setText(_translate("Form", "save"))
    57. self.label.setText(_translate("Form", "HTTP thread count"))
    58. self.threadcountLineEdit.setText(_translate("Form", "0"))
    59. self.label_2.setText(_translate("Form", "s"))
    60.  
    61.  
    62. class Ui_MainWindow(object):
    63. def setupUi(self, MainWindow):
    64. MainWindow.setObjectName("MainWindow")
    65. MainWindow.resize(331, 351)
    66. sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
    67. sizePolicy.setHorizontalStretch(0)
    68. sizePolicy.setVerticalStretch(0)
    69. sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth())
    70. MainWindow.setSizePolicy(sizePolicy)
    71. MainWindow.setMinimumSize(QtCore.QSize(331, 351))
    72. MainWindow.setMaximumSize(QtCore.QSize(331, 351))
    73. MainWindow.setStyleSheet("background-color:rgb(250, 255, 151)")
    74.  
    75.  
    76. if __name__ == "__main__":
    77. import sys
    78. app = QtWidgets.QApplication(sys.argv)
    79. MainWindow = QtWidgets.QMainWindow()
    80. ui = Ui_MainWindow()
    81. ui.setupUi(MainWindow)
    82. MainWindow.show()
    83. ui = Ui_Form()
    84. ui.setupUi(MainWindow)
    85. sys.exit(app.exec_())
    To copy to clipboard, switch view to plain text mode 

    setupUi function of Ui_MainWindow is properly applied, but the one of Ui_Form is not applied.
    How can I solve this problem?

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: A Widget is not updated

    Fix line 84 in the code you posted above.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Jul 2018
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: A Widget is not updated

    Sorry, I have no idea what I should do with the line 84.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: A Widget is not updated

    Try "ui.setupUi( Form )".
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 3
    Last Post: 15th January 2016, 14:13
  2. QWebView not updated.
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 0
    Last Post: 23rd June 2013, 06:57
  3. Replies: 0
    Last Post: 18th November 2010, 16:48
  4. Replies: 5
    Last Post: 17th June 2009, 14:01
  5. elements not updated
    By danesh in forum Qt Programming
    Replies: 2
    Last Post: 2nd April 2009, 08:35

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.