[PyQt] PyQt documentation where PyQt function is not same as Qt C++ function

Florian Bruhin me at the-compiler.org
Mon Nov 27 16:40:07 GMT 2017


Hi,

On Mon, Nov 27, 2017 at 03:53:28PM +0000, J Barchan wrote:
> [Also cc'ed to "Florian Bruhin", as I believe you have indicated that you
> are "The Man"!]

I'm just a "normal" user of PyQt ;-)

Phil Thompson is "the man", but as mentioned on [1], this mailing list is the
right place to ask :)

[1] https://www.riverbankcomputing.com/support/help

> I'm getting a little peeved by the problems which arise when you seem to
> have chosen to make a PyQt function differ somewhat (in return result, so
> far) from the corresponding Qt C++ function, but no documentation to
> explain can be found.  (This may apply only to PyQt5, not PyQt4, I don't
> know.)
> 
> I was just trying to write an override in my own class for
> QRegularExpression.validate().  The Qt documentation (
> http://doc.qt.io/qt-5/qregularexpressionvalidator.html#validate) shows:
> 
> QValidator::State <http://doc.qt.io/qt-5/qvalidator.html#State-enum>
> QRegularExpressionValidator::validate(QString
> <http://doc.qt.io/qt-5/qstring.html> &*input*, int &*pos*) const
> So I expect it to return a QValidator.State.  However, QtGui.pyi shows:
> 
> def validate(self, input: str, pos: int) ->
> typing.Tuple[QValidator.State, str, int]: ...
> 
> So this is a tuple, with an extra str & int returned.
> 
> Apart from the fact that it's a tuple instead of a plain enum returned, I
> have *no idea* what the extra str & int might be, what to do with them, etc.

Probably the fixed input and new position.

> If you *really* need to return different information from the C++ function
> (why?  to do with overloading not working the same??)

Because C++ can write a new value back to input/pos (because they're passed as
reference), but Python can't.

Florian

-- 
https://www.qutebrowser.org  | me at the-compiler.org (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072  | https://the-compiler.org/pubkey.asc
         I love long mails!  | https://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20171127/37dedb1e/attachment.sig>


More information about the PyQt mailing list