ChatCrawlersearch across public Telegram Open the app
Q

Qt for Python (PySide/Shiboken)

20 June 2020
2020-06-20×
20 June 2020
C
declare it as a primitive type
.
Yes, I remove id from bindings.xml - <typesystem package="DaggyPy"> <value-type name="TestCommand"> </value-type> </typesystem>
.
And got this error - (bindings) [4ms] Resolving typedefs (0)... qt.shiboken:-1: error: (bindings) skipping field 'TestCommand::id' with unmatched type 'int'
<primitive-type name="int"/>
FreyaСсылка
pretty sure you will be able to reproduce it in Qt/C++ :/ usually you don't see those anomalies with pyside/pyqt
(well, the internal error probably isn't my fault)
F
but agreed, nothing Python-specific, just thought some people here could have a good laugh like I had when this happened :D
Ссылка
click to show
It's really probable that many issues you have, will be solve in the typesystem of pyside, so I recommend you to clone pyside-setup and check the ".xml" files there. Also, there is already a project using shiboken on a diff project, Qwt, I think I already sent you the link, but in any case , you can check it out: https://github.com/qt-ps-americas/pysideqwt
you already connected two widgets
.
Cristián 🥑;)
Ok, I changed id type to QString, and got several errors about namespaces. My bindings.h - #include <QString> struct TestCommand { QString id; }; My bindings.xml: <typesystem package="DaggyPy"> <primitive-type name="QString"/> <value-type name="TestCommand"> </value-type> </typesystem> And I got next errors: (bindings) [329ms] Generating enum model (2)... qt.shiboken:-1: error: (bindings) Anonymous enum (Q_COMPLEX_TYPE, ... , Q_RELOCATABLE_TYPE) does not have a type entry qt.shiboken:-1: error: (bindings) Enum 'QtMsgType' does not have a type entry
on the pyside-setup repo
I added <include file-name="QString" location="global"/>
And got success compilation )
.
I began to understand how to use it )
you need to be careful
for example, check the typesystem inside QtCore (in the pyside-setup) repo
that has the proper code to interpret a QString into python
you need to add some manual intervention there
C
because maybe it "compiles", but it will not properly work
.
@cmaureir by the way, is any examples how to share signals/slots?
C
as long as you declare them as "slots' and "signals" in your C++ source
Yes, but for that you just need to copy what you see in the QtCore's typesystem
C
and that will be enough, shiboken will know how to deal with the QString in any scope
.
Cristián 🥑no, just the entry for QString
(bindings) [307ms] Running Source generator... (bindings) collectContainerTypesFromConverterMacros:-1: error: Cannot translate type "const char *": Unable to build meta type for "const char *": Unable to translate type "const char*": Cannot find type entry for "char".
<primitive-type name="QString" target-lang-api-name="PyUnicode"> <include file-name="QString" location="global"/> <conversion-rule> <native-to-target file="../glue/qtcore.cpp" snippet="return-pyunicode"/> <target-to-native> <add-conversion type="PyUnicode" file="../glue/qtcore.cpp" snippet="conversion-pyunicode"/> <add-conversion type="PyString" check="py2kStrCheck(%in)" file="../glue/qtcore.cpp" snippet="conversion-pystring"/> <add-conversion type="Py_None" file="../glue/qtcore.cpp" snippet="conversion-pynone"/> </target-to-native> </conversion-rule> </primitive-type>
.
I don't have access to ../glue/qtcore.cpp for example, how this work?
you need to create a file to store the snippets, maybe you can call it "glue_qtcore.cpp" so you can copy the snippets that are declred there "return-pyunicode", "conversion-pyunicode", etc... in your local file.
C
the file is in the repository...
C
no, in that case you don't need anything special, <primitive-type name="std::string"/>
.
If I will use only C++ native type, will this easier?
but if you want to use any std container, you need to add the proper behavior including the conversions between Python and C++
.
If I understand correctly, I cannot use definitions from QtCore, I must redefine them in my bindings.xml and it looks like a nightmare )
I think you will find no binding generator that provide a simple conversion between Qt and Python, since you need to handle the conversions. That's why with shiboken, you can just copy the things that are already inside the repository
you are using shiboken, after building it
you can just include what we have in PySide
did you check the link I sent you?
We ship all the Qt xml files
<typesystem package="pysideqwt"> <load-typesystem name="typesystem_widgets.xml" generate="no"/> <load-typesystem name="typesystem_gui_common.xml" generate="no"/> <load-typesystem name="typesystem_core_common.xml" generate="no"/>
C
and then you have all the declarations
I wrote next bindings.xml: <typesystem package="DaggyPy"> <load-typesystem name="typesystem_core_common.xml" generate="no"/> <value-type name="TestCommand"> </value-type> </typesystem>
And I got next errors: qt.shiboken:-1: error: (bindings) Duplicate type entry: 'QMessageLogContext' (bindings) [441ms] Fixing class inheritance... qt.shiboken:-1: error: (bindings) template baseclass 'QCborStreamReader::StringResult<QByteArray>' of 'QCborStringResultByteArray' is not known
.
qt.shiboken:-1: error: (bindings) template baseclass 'QCborStreamReader::StringResult<QString>' of 'QCborStringResultString' is not known
which PySide you built?
and which Qt do you have installed in your system?
the definition of that is inside the typesystem_core_common:
C
<typedef-type name="QCborStringResultString" source="QCborStreamReader::StringResult&lt;QString&gt;" since="5.12"/>
can you check the typesystem_core_common.xml that you have in your installation and see if you have the line for QCborStringResultString?
C
that was added in 5.12
if you have questions, you can just post them here
and I will check them tomorrow or on Monday
.
Thank you very much, have a nice weekend! )
I wondered: how do you handle secrets in your Qt applications? Thinking along the lines of API tokens here.
A
For my own projects, I'd store them in a .env file and use a lib to read that file and turn it into a set of environment variables … But a Qt application is likely meant to distribute to other (non-technical) persons. Are there best practices?
Calendar: June 2020
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