ChatCrawlersearch across public Telegram Open the app
Q

Qt for Python (PySide/Shiboken)

25 June 2021
2021-06-25×
25 June 2021
I
Luis Falcontext not yet in the index
Thanks a lot for sharing. Glad to see a good project using PySide+QML... Reading the title i was hoping for a mobile support for pyside2... before discovering is only about pine64 stuff 😅 Time to buy a PinePhone 😜
A
Anupam BasakСсылка
Ссылка
click to show
Going live in ~20mins at KDE Akademy 2021 In this session I will try to include : - Passing arguments of type lists - Passing list of custom python data objects and parsing the data on QML side - QML Listview and its population from custom python data objects - Properties , notifyable properties Time : 9UTC Location : Room 3 (https://meet.kde.org/b/akademy-bof-3)
i have a project where i need to get data through api calls and then add part of that data on a qtreeview.
I
the generation of the tree, the first time takes about 17 seconds, so i am trying to use qthread to get the data
how are you fetching the data from api calls?? which library are you using??
A
QNetworkAccessManager works on top of Qt event loop and will be async in nature by default
@cmaureir : can you suggest me links against the use of context property to expose classes to QML? I would read about it before ask for a better solution.... I don't want qml dev team track me 😂🤭
L
I'm using plasma mobile.
C
notice the time stamp
D
Hey guys I discovered qt today only and am really interested in building ux for my python projects Can anyone share some learning resources please?
C
DeKayHey guys I discovered qt today only and am really interested in building ux for my python projects Can anyone share some learning resources please?
If you are more into reading documentations and guides: https://doc.qt.io/qtforpython/quickstart.html for a simple application. https://doc.qt.io/qtforpython/tutorials/index.html to learn a few concepts and common usages https://doc.qt.io/qtforpython/examples/index.html for examples. if you are more into videos: https://doc.qt.io/qtforpython/videos.html In the case you are looking for something different, please share it with us, so we can either improve the docs or discover other resources that other people on this group might know.
C
Hey @anupambasak27 thanks for hosting two sessions at Akademy! Little question: Which features of PyCharm would you like to have in QtCreator? We want to approach the QtCreator team to analyze if they believe it's worth improve it to get a better Python support. (usually it's a problem...because QtCreator was designed for C++, so many things make little sense in Python land) but since people like you are relying on Creator to do QML things...I was curious.
A
I will be sharing the two session videos after editing them
A
Will share the link here once done
K
I'm in US East coast, so just woke up. Your talk was at 5am my time heh. I should have kept abreast of the akademy talk schedule!
K
Ivan Tarozzi@cmaureir : can you suggest me links against the use of context property to expose classes to QML? I would read about it before ask for a better solution.... I don't want qml dev team track me 😂🤭
Read the C++ Qt docs on the context property usage. I think it may explain why there are better approaches. Dropping in things into the global QML engine context has the same negatives that using a global python variable has - global namespace pollution. No easy way to organize your properties you're sharing to QML. However, it's a really easy way to share data from Python or C++ (host language I guess?) to QML. Though I believe things got easier with Qt 6 and PySide6 in this regard.
Keith KyzivatRead the C++ Qt docs on the context property usage. I think it may explain why there are better approaches. Dropping in things into the global QML engine context has the same negatives that using a global python variable has - global namespace pollution. No easy way to organize your properties you'r
Ok, I saw the video suggested by @cmaureir and actually he said setContextProperty will be deprecated then removed. I know the point of @Keithel about global vars. But I have not yet found a solution in my use case, except to use qmlRegisterSingletonInstance instead of setContextProperty. May be I use a wrong pattern, but in my HMI applications I use a single main class (C++ or python) exported as Context property. That class collect data via serial connection to device and handle the state machine for business logic. So, I can't create a new instance for each QML page. QML page needs to access class properties to show data and send command (slots). The alternative way could be use my main class as unexported, and then export other gateway classes as "Registered Type", but in this case I need to implements a sort of communication between QML exported classes and the main one. What about a better practice?
True true, and I have been in your situation, and have also settled on qmlRegisterSingletonInstance before. I think maybe in your case some classes in Python could abstract out the state machine and present it in a more modular way that could be shared as individual QML components.
K
Though I understand your pain. Been there! Not with Python but C++
C
My phrase was a self-criticism haha because I haven't updated the examples since the QML team told us it was a bad practice :(
How exactly is the python interpreter that Qt Creator selected? I have a new project I created, and when I launch it, it's using a venv environment I created ages ago with PySide2 5.12.9...
I see there is a Python category in Qt Creator settings, to see all the python dirs/environments that were discovered, and a way to select a default one, but that defaut one is not what is used when I hit ▶️ Run
K
It mentioning "Default" suggests that there is a way to select python interpreter used per project, but I don't see a way to set that
I use the run configuration all the time for C++ based projects.. For some reason I didn't think Python projects used that I guess...
That was the problem.
K
This is basically my first time trying to do Python dev in Qt Creator.
I
Me too. And is not really clear to me how creator use python files and run/debug applications. Until now I use creator only for QML editing, and VSCode for python editing and run
K
actually, more than superfluous - they have no meaning at all when it comes to Qt for Python development, and add confusion.
I
another doubt is related to IDE project file. When I create python project in QtCreator, it create only a <myprj>.pyproject file listing py and qml files (in my case) with pythonic syntax. And is not creating a .pro file. But to use (e.g.) translations integration I think I need to create one with "TRANSLATIONS = " statement.... or not?? 😳
K
Maybe this can be turned into a Qt Creator request - to at least create the boilerplate in there for adding translations, and any other things that could be set in the project file.
Calendar: June 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