ChatCrawlersearch across public Telegram Open the app
Q

Qt for Python (PySide/Shiboken)

19 January 2021
2021-01-19×
19 January 2021
I
QTextEdit().clear() when i call it make my application note responding and closes, what should i do?
Hi everyone, I am Cristo from Spain and I am discovering Pyside 6. I would like to taste Qt Quick - QML flavour but I am lost a little with the documentation. I've only found a few Qt Quick tutorial but I miss some kind of "reference" that tells how is the proper way to load qml files, what are the qml components, etc. Could you bring me a point to start? Thanks in advance and sorry if it's not the place to this question 🙏
K
I have another problem with qml and Pyside6. On Windows, I have this two files in the same directory and I am using Python 3.9.1. If I run this hello world I always have Network error and I don't see the QML component in the window hello.qml file import QtQuick 2.0 Rectangle { width: 200 height: 200 color: "green" Text { text: "Hello world" anchors.centerIn: parent } TextInput { id: textInput1 x: 60 y: 112 width: 80 height: 20 text: qsTr("Introduzca texto") font.pixelSize: 12 } } hello_qml.py file import sys from pathlib import Path, WindowsPath from PySide6.QtWidgets import QApplication from PySide6.QtQuick import QQuickView from PySide6.QtCore import QUrl app = QApplication(sys.argv) qml_file = str(Path(__file__).parents[0] / 'hello.qml') # qml_file = str(WindowsPath(__file__).parents[0] / 'hello.qml') print(f'qml file = {qml_file}') url = QUrl(qml_file) view = QQuickView() view.setSource(url) view.show() sys.exit(app.exec_())
Maybe add an assert url.isValid() to be sure
F
Ah, you're passing it as a string though - so yeah, that is likely the problem
F
No idea about that one, I don't use qml
Cannont load library: ...\lib\site-packages\PySide6\qml\QtQml\WorkerScript\workerscriptplugin.dll
Ë
id 1315330360seems at my side it's working
Where do you get this WidgetClass().function() scheme from? 🤔 I'd suggest you have a good look at the huge examples folder from the PySide package (for instance ...Lib/site-packages/PySide6/examples/widgets/animation/states/states.py)
F
That doesn't show that syntax anywhere though?
But we DO have a whole lot of good examples!
Ë
Just a tiny question I was always asking myself: Is .show() / .hide() completely identical to .setVisible(True) / .setVisible(False)? I always "feel" like show() does a bit more work. But thats based on hot air 😄
For hide(): "This function is equivalent to setVisible(false)."
The example is broken in the PySide6 examples, right?
Ë
again: QWebEngineView has also a pretty good example code file shipped with PySide! 😉 ...\Lib\site-packages\PySide2\examples\webenginewidgets\simplebrowser.py
F
QPlainTextEdit().clear() is valid Python code as well, but it doesn't do anything useful
F
Can you show some code? Ideally a minimal example? If you describe your code but use different code than what you actually have, this really makes it hard to help you
if link in self.web_scrapped_text: print('using cached') self.ui.scraped_content.clear() self.ui.scraped_content.appendHtml(self.web_scrapped_text[link])
I
that's a function and when i call it, the app crashes
F
I don't see a reason why it should crash in that snippet
I
i do it like 3 times success, then after like on the 4th attempt crashes
F
What does "crashes" mean exactly? What output do you get?
F
What if you run it in a terminal? Also, what if you add import faulthandler; faulthandler.enable() somewhere at the top of your file?
I
you're good thanks, it's working fine now :)
F
faulthandler should give you more information on the crash, it shouldn't make the crash disappear
I
Hhhh, maybe that the cure, so far the GUI is not disappearing, but the app keeps saying not responding
F
you should now see some output if you run it in a terminal
I
it haven't crashed yet, but i'll see that, faulthandler.enable() maybe does more than that, maybe it ignores the error
Ë
this just works for me. clears the field 100 times no sweat.
I
ohh, seems like it's working, maybe it's because i'm adding huge content before i call .clear()
Фотография
click to show
fires setText() and clear() with random garbage until an iteration exceeds 1sec
PySide6 is a little quicker than 2 here
Ë
Never crashed on me tho :/
I
guess i'm have to switch to pyside6, what the install pip command?, pip install pyside6?
Yep thats it. But beware! Although its out and solid number 6.0.0. .. there are some modules missing! Some of the examples do not yet work.
depending on the project you're doing id rather stick to PySide2
Ë
The webview thing for instance!! .... PySide2
I
ERROR: Could not find a version that satisfies the requirement PySide6 ERROR: No matching distribution found for PySide6
F
Are you on Python 2? If not, try upgrading pip first.
C
@dannie360 I recommend you not to rush into things without evaluating first. @ericgoodsoulbad just mentioned that webview is not available on PySide6, and since you are asking questions about it, it will not work. The fact that you asked how to install pyside6, make me think you are not familiar with the documentation nor wiki page, please take a couple of minutes with a coffee/tea and get familiarized with those two sources of information: doc.qt.io/qtforpython (docs) pyside.org (wiki)
Calendar: January 2021
Archive by month
Open in Telegram Каталог площадок Искать в ChatCrawler

A snapshot of an open public feed from the search index ChatCrawler — “Google for public Telegram”; refreshed as the venue is crawled. Times are UTC.

Public content only, official Telegram API. About · FAQ · What we do not do · Remove a page · Catalog