How to call "count" method of QLayout ?

How to call "count" method of QLayout ?

denisT.MaxDoctor
Advisor Advisor
402 Views
2 Replies
Message 1 of 3

How to call "count" method of QLayout ?

denisT.MaxDoctor
Advisor
Advisor

here is a simple MXS snippet:

 

wd = python.import "PySide2.QtWidgets"
v = wd.QHBoxLayout()
b = wd.QLabel()
v.addWidget b
v.itemAt 0

 

last line returns QWidgetItem as expected, and count of the layout items must be 1

but:

 

v.count()

 

fails with 

-- Type error: Call needs function or class, got: 0

 

I tried invokeMethod using QMetaObject, I tryied to find the "count" method using indexOfMethod... nothing works.

 

Is there anything else I missed?

 

thanks,

 

 

... and ... of course I tried to call "count" as a property:

v.count

it's doing something other and returns always 0. I guess this "count" is a part of PyWrapperBase which screws the normal method behavior.

 

0 Likes
Accepted solutions (1)
403 Views
2 Replies
Replies (2)
Message 2 of 3

denisT.MaxDoctor
Advisor
Advisor

of course I solved the problem somehow for myself and added a visible mxs method to get the correct count value, but still very interested in getting a better solution.

0 Likes
Message 3 of 3

denisT.MaxDoctor
Advisor
Advisor
Accepted solution

found :

 

 

 

f = <py_builtin>.getattr <qlayout> "count"
f()

 

 

If you know a better solution, please let us know. Thanks.

 
0 Likes