-
Notifications
You must be signed in to change notification settings - Fork 31
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
Set properties using keyword arguments in constructor #147
Comments
Well this is fun. So, I agree that it works at run time and therefor should work when type checking. https://replit.com/@altendky/OldfashionedRemoteComputergames-2 from PyQt5 import QtCore
from PyQt5 import QtWidgets
print(QtCore.PYQT_VERSION_STR)
application = QtWidgets.QApplication([])
scroll_area_1 = QtWidgets.QScrollArea(widgetResizable=False)
scroll_area_2 = QtWidgets.QScrollArea(widgetResizable=True)
print(scroll_area_1.widgetResizable())
print(scroll_area_2.widgetResizable())
But... it isn't documented for Qt itself. https://doc.qt.io/qt-5/qscrollarea.html Anyways, we're for accuracy so I'll plan on putting together a PR. |
This is a feature of PyQt that's gonna be a pain to support:
So every single widget's constructor supports kwargs for every single one of their Qt Properties |
yay... |
"self.dialog_groupbox = QtWidgets.QGroupBox(objectName="job_post_box")" gives me: "error: No overload variant of "QGroupBox" matches argument type "str" Should this be considered the same issue, or do you want me to create a separate issue? |
Since @BryceBeagle identified this as a systemic issue, I'm not going to be tackling them all. If you want to add them, just direct PRs would suffice. No need for tickets first. |
Well here's a way to get all the Qt Properties of an object: from PyQt5.QtWidgets import QScrollArea, QApplication
app = QApplication([])
meta = QScrollArea().metaObject()
for prop_idx in range(meta.propertyCount()):
prop = meta.property(prop_idx)
print(prop.name(), prop.typeName())
An absolute massive amount of properties. Not sure if we want to support all this, but if we do I'm thinking we could script this operation somehow. Unfortunately, this snippet here requires knowing how to properly instantiate the |
Something interesting I noticed is that some properties (e.g |
*uuughHGHGHGHGHH* I tend to think our focus should be on Qt6 and maybe trying to get Phil fixing whatever issues we find rather than developing our own modifier or generator. But who knows what will really work out... |
I agree, this should probably be something to get Phil to implement upstream. Unfortunately, I haven't had the best experience using the mailing list in the past... I have been unable to properly reply to a thread without also turning off the email digests... 😐 |
It's not like it's a high traffic maillist. Aren't half the digests a single message anyways? But, I can try again when we get to working with PyQt6. I didn't get far with 'there are lots of changes, take a look at the diff and the PRs and the changelog'. So I guess the next pass will be one by one sequential reports. What do you think @BryceBeagle and @The-Compiler, should we leave this as 'will accept PRs but presently no plan to fully implement'? |
My stance is still that we should strive to automate those fixes rather than doing them manually - but then again I haven't been contributing much, so it's not like I have much of a say 🙂 |
Is there a reason to not be fixing SIP/PyQt? Is it a bad system? Too much hassle to go through the half-open-source development path? Or, maybe you include fixing upstream generation in 'automate those fixes'. Also, my statement was 'we are not prioritizing automating them and also will not be manually doing them en-masse'. Which I think is somewhat just a different perspective on what you wrote. |
An alternative approach to find all the properties of an object is to parse Qt documentation. This can be automated. |
This issue was incorrectly closed. We should strive to support setting all properties using the object constructor . |
Can we have |
@senyai interesting suggestion but we would be validating incorrect code in this case. I prefer a long term correct solution, or patching as people report the problems. |
"self.scroll_area = QtWidgets.QScrollArea(widgetResizable=True)"
generates following error message:
error: Unexpected keyword argument "widgetResizable" for "QScrollArea"
The text was updated successfully, but these errors were encountered: