Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finding costum widgets with findChild #9

Open
wytr opened this issue Dec 8, 2021 · 2 comments
Open

Finding costum widgets with findChild #9

wytr opened this issue Dec 8, 2021 · 2 comments

Comments

@wytr
Copy link

wytr commented Dec 8, 2021

Im trying to access a costum PyLineEdit widget which was added to the row_1_layout in the setup_main_window.py with the following row in main.py:

  • self.ui.load_pages.row_1_layout.findChild(type)

which kind of type do i have to look for? Im always getting None.

.isEmpty() is returning false though.

Already tried PyLineEdit aswell as QLineEdit which it inherits from(?)

->class PyLineEdit(QLineEdit):

@commanderk33n
Copy link

To get a widget from a QLayout, you have to call its itemAt(index) method. As the name of this method implies, it will return an item instead of a widget. Calling widget() on the result will finally give you the widget:

myWidget = self.myLayout.itemAt(index).widget()

@apolloneo
Copy link

apolloneo commented Mar 8, 2022

To get a widget from a QLayout, you have to call its itemAt(index) method. As the name of this method implies, it will return an item instead of a widget. Calling widget() on the result will finally give you the widget:

myWidget = self.myLayout.itemAt(index).widget()

how about events? for example, I added customized PyPushButton to the page, and in "setup_main_window" I added
`self.my_btn = PyPushButton(text="button", radius=8)

self.my_btn.setMaximumHeight(25)

///both self.btn_clicked and self.btn_released are defined in "main.py"

self.my_btn.clicked.connect(self.btn_clicked)

self.my_btn.released.connect(self.btn_released)
`
so in "main.py" how can I receive the event that triggered by clicking the customized push button? currently, it is checked by object name / btn_id.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants