[PyQt] Problems with getting text from QLineEdit

michael h michaelkenth at gmail.com
Tue Jan 17 00:11:41 GMT 2017

> print(self.pat_add_gui.ui.txtlname.text())
> AttributeError: 'bool' object has no attribute 'pat_add_gui'
> This indicates that 'self' is a bool object which would be a mistake on
your part.

> Any ideas how I can get the text from these lineedits???
You haven't provided enough code for anyone to help you. That being said,
given a .ui with a QLineEdit named 'testLineEdit' the below script will
print its text:

import sys
from PyQt5 import QtWidgets, uic

Ui_MainWindow, BaseClass = uic.loadUiType('test.ui')

class MainWindowTest(BaseClass, Ui_MainWindow):
    def __init__(self):
        super(MainWindowTest, self).__init__()
        print (self.testLineEdit.text())

if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    window = MainWindowTest()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20170116/94326294/attachment.html>

More information about the PyQt mailing list