Need help with adding Widget
-
Pardon any faux pas as I am a newbie here.
I have an RPI 4 running Raspbian 10 and using QT Designer 5.11.3.
It appears that V6 is not available on the RPI.
I have designed and have been running a Radiant heat system under this for some time now using the RPI GPIO's and links to my MYSQL server for recording and it has been working well for years.
Here is a screen shot.The problem I have is that I'd like to add code for handling some forced air flue dampers and need widgets that will show the positions of them.
I found a widget online called qscale (Examples)I could use one of these, however I cannot seem to import the darn things.
The files contained in the qscale download are 2 .cpp's a .h and a .pro.
I cannot find nor figure for the life of me how to make this a part of QT Designer.
I have searched the web and documentation and am exceedingly perplexed.
Can anyone help ?
The files are main.cpp, qscale.cpp, qscale.h and QScale.pro thats it. No .ui. -
@bobd
Are you aware that one does not have to use Designer or have a.ui
file? If that sample is truly complete, look in the.cpp
file and see if it is drawing those dials via code?You can create widgets "dynamically" in a Qt C++ program, so you could do that by calling the
qscale
code. Or you can use promotion (simple) or custom widgets (complicated) if you really want to add anything visual at design-time to Designer.You could probably just add the
qscale.{cpp,h}
files to your Creator project. -
I am pretty much ignorant in the ins and outs.
What I have is 2 programs if you will, Thonny and QT Designer.
Thonny appears to be a Python editor and can also run the code and give error/status messages thereof.
QT Designer allows me to layout the screens with widgets (fields) in a (relatively cumbersome way).
The python code as loaded in Thonny then references those widgets/fields and other things such as system calls to files,
GPIO interactions and anything else Python code can do generally speaking.
QT Designer uses a primary .ui file. The Python code loads the .ui file, thus rendering a screen as layed out in Qt Designer.
I am using the structure given and not versed in any other way.
I do not even understand what a "project" is. Thonny only loads/saves .py files. Designer uses .ui files.
Neither has any references to "project" either in menus or otherwise.
As I said, I am relatively ignorant. -
@bobd said in Need help with adding Widget:
QT Designer uses a primary .ui file. The Python code loads the .ui file,
The example you picked, assuming it works as a standalone program, is written in C++. And apparently does not produce the dials via a designer or a
.ui
file.Unless you wish maybe to rewrite the
qscale
code in Python (probably not a task for you) I would suggest it is likely not to be of use for your purpose, from what I understand.I know nothing about "Thonny".
You should reference where you got the
qscale
stuff from, which looks like https://store.kde.org/p/1132178/. And I notice thereIf you use the widget, I'd be glad if you leave a comment. This might encourage me to create a Designer plugin or do other further work at other parts of the code.
so nothing is apparently available for Designer anyway.
But I do see
Tanks for the Python port.
so something has been done for Python. Probably https://github.com/altendky/st/blob/3d70302313375001b2dcc27f086be2a98bea74ed/epyq/qscale.py ?
That still means there is no
.ui
file for it for the way you want your system to work. -
Yes, you are correct.
Yes, I have neither the time nor the inclination to rewrite code for a simple scale meter.
The .ui file is an xml file that references no other files.
The .py files do of course use system includes such as sys, RPi.GPIO, time and the like.
Do you know of any easily usable widgets for QT Designer such as the qscale ?
Something I can incorporate in my Designer ?
I just looked and I do have QT Creator.
I loaded it and was completely lost.
Thank you for the responses and help by the way. -
So I jumped into QT Creator. I created a project and understand the basic layout ok (I think).
But it does not appear to have any allowance for Python code. It appears to be C++ is this right ?
My option is to Quick learn/recode in C++ all I have done in Python to use the Creator Yes ?
By doing this, it would be easier to incorporate widgets I assume as Designer is limited. -
@bobd
Qt Creator supports Python development.
https://doc.qt.io/qtcreator/creator-python-development.html
https://doc.qt.io/qtforpython-6/tools/pyside-designer.html#pyside6-designer
https://www.pythonguis.com/tutorials/pyside6-first-steps-qt-designer/How any of this relates to your use of "Thonny" I do not know.