[PyQt] QMessageBox, selectable text, different behaviour among OSes

Elvis Stansvik elvstone at gmail.com
Thu May 12 07:43:12 BST 2016


Den 10 maj 2016 4:25 em skrev "Leonardo Corato" <leocor at gmail.com>:
>
> Hello everybody,
>
> this is my first post. Pardon me whether it has aldready been asked.
> I made a small program with PyQT (5) and the result is shown into a
QMessageBox.
> In Windows I cannot select the text with the mouse while in Linux I can.
>
> I suppose in Windows there's a different default that in Linux.
> I saw there's an option in QT to force the text to be selectable, said mb
is the instance of QMessageBox
mb.setTextInteractionFlags(Qt::TextSelectableByMouse) but How can I apply
it in Python?
>
> My snippet:
>     def tagconvert(self):
>         i = self.lineEdit.text()
>         if len(i) >= 0 and i.isdigit():
>             d = (int(i)).to_bytes(4, byteorder='little')
>             converted = ''.join('%02x' % c for c in d)
>             msg=QMessageBox()
>             msg.setText(converted)
>             msg.setWindowTitle("Tag Convertito:")
>             msg.setTextInteractionFlags(TextSelectableByMouse);

Should be

msg.setTextInteractionFlags(Qt.TextSelectableByMouse);

after

from PyQt5.QtCore import Qt

I think.

Elvis

>             msg.exec_()
>             print(converted)
>         else:
>
> Thanks and best regads,
> Leo
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> https://www.riverbankcomputing.com/mailman/listinfo/pyqt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20160512/9b32bc09/attachment.html>


More information about the PyQt mailing list