Python Forum
Simple printing the text for a QLineEdit
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple printing the text for a QLineEdit
#15
I am confused by this

Quote:or if an outside function(function outside of a class) calls a class, again only inherits the methods of the class being called.

Inheritance affects which code runs when a method is called, but it is incorrect to say that calling a method of an object "inherits" something. I can ask a hardwareTab object for it's width and height for example. Your code does not define these methods, but they are defined by QWidget, and because they are methods of a superclass, they get inherited by hardwareTab. So you could say that inheritance affects how a method call is bound, how Python figures out what code to execute, but calling a method does not result in the caller "inheriting" anything.

I think any confusion you have about function calls and inheritance is caused by your enterNewHardware class. In some of your posts enterNewHardware was a function, and then later you made it a class. enterNewHardware() calls a function when enterNewHardware() is a function and it creates an instance of a class when enterNewHardware is a class. As a result, this code does really different things based on if enterNewHardware is a function or a class.
self.enButton.clicked.connect(enterNewHardware)
If enterNewHardware is a function, pressing the button calls the function with no arguments. If enterNewHardware is a class, pressing the button creates a new instance of the class, and enterNewHardware.__init__() is called.
thewolf likes this post
Reply


Messages In This Thread
RE: Simple printing the text for a QLineEdit - by deanhystad - Mar-06-2021, 02:26 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] QLineEdit Caret (Text Cursor) Transparency malonn 5 2,926 Nov-04-2022, 09:04 PM
Last Post: malonn
  How to accept only float number in QLineEdit input ism 5 28,698 Jul-06-2021, 05:23 PM
Last Post: deanhystad
  PyQt5: How to retrieve a QLineEdit by its name ? arbiel 4 8,027 Oct-21-2020, 02:35 PM
Last Post: arbiel
  Two QlineEdit box, which interrelated GMCobraz 1 2,460 Aug-14-2020, 07:15 PM
Last Post: deanhystad
  [PyQt] Dynamically add and remove QLineEdit's GMCobraz 3 7,241 Jun-23-2020, 07:01 PM
Last Post: Yoriz
  prompt for input in qlineedit GMCobraz 3 3,263 Jun-22-2020, 01:51 PM
Last Post: GMCobraz
  [PyQt] display content from left to right in QComboBox or QLineEdit mart79 2 2,365 May-30-2020, 04:38 PM
Last Post: Axel_Erfurt
  How to loop through all QLineEdit widgets on a form JayCee 6 6,794 Apr-03-2020, 12:15 AM
Last Post: JayCee
  [PyQt] How to clear multiple Qlineedit in a loop mart79 6 7,855 Aug-15-2019, 02:37 PM
Last Post: Denni
  How to validate multiple QLineEdit widgets without addressing them separately? mart79 3 4,315 Aug-08-2019, 12:50 PM
Last Post: Denni

Forum Jump:

User Panel Messages

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