Python Forum
[PyQt] Why lineEdit is showing text like this ??
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] Why lineEdit is showing text like this ??
#3
Okay let us assume that your UI file (which you ought not be using for this very reason) has a QLineEdit object called MyLineEdit (which it would never have since that is not how it goes about referencing variables). Then you should simply be able to do the following (I have not tested this because I never use UI files as they are a waste of time and effort):

ui.MyLineEdit = ClassLineEdit()

You are thus replacing whatever object you created in the UI file with your own Class Object.

Also when using super( ) you need to do the following:

class lineEdit(QtWidgets.QLineEdit):
     def __init__(self, parent):
        super(lineEdit, self).__init__()   
Note you most likely have no reason to pass a handle to your Parent to the base QLineEdit so do not do so.

Next had you made your import statement more direct and to the point as such:

from PyQt5.QtWidgets import QLineEdit
you could have done the following:

class NewLineEdit(QLineEdit):
     def __init__(self, parent):
        super(lineEdit, self).__init__()
-- or not even use super and do this --
class NewLineEdit(QLineEdit):
     def __init__(self, parent):
        QLineEdit.__init__(self)
And lastly are you even using the handle to the parent within your Line Edit objects or are you just passing it in unnecessarily -- if not needed we can simplify it as follows:
class NewLineEdit(QLineEdit):
     def __init__(self):
        QLineEdit.__init__(self)
Reply


Messages In This Thread
RE: Why lineEdit is showing text like this ?? - by Denni - Sep-06-2019, 08:50 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyGUI] Showing text in QTableView sequence 0 3,166 Jan-20-2019, 05:00 PM
Last Post: sequence
  [PyQt] Need Help about comboBox and lineEdit DeanONeil 1 2,757 Oct-13-2017, 05:42 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020