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.
-
JonB, again, thank you for the reply.
FYI: Thonny is a free and open-source integrated development environment for Python. It supports different ways of stepping through code, step-by-step expression evaluation, detailed visualization of the call stack and a mode for explaining the concepts of references and heap in addition to error assistance. It is simply a tool for trying to make coding and running python code a bit easier, much as QT Designer is intended to make coding GUI's easier and more convenient. Thonny does NOT have ANY GUI WYSIWYG such as QT Designer has so I use Designer strictly for this.
Python allows GUI design using qtpy5 libraries (installed in the O.S) or other versions directly included in the python script and will load the .ui Designer file via a loadUi(;filename', self) command. It may be possible to load a .pro , .h or .ccp files, however integrating them in or over a loadUi is a bit above my pay grade.
Coding can still be done manually directly in files and compiles done in normal command line mode in both including GUI's using Qt and Python using also Qt libraries.
So Thonny is simply an IDE 'editor' if you will such as QT Creator and QT Designer are in effect, only simpler.
However in my mind most of these IDE's have become so complicated and cumbersome that one feels that a separate college degree is required just to use them. Ofttimes I find it easier to edit the code directly.
As to your links, they are wonderful and would be of great assistance if qt v6 was available on the Arm Raspberry Pi's. Unfortunately the only current way to get to Qt V6 both Creator et al and qtpy6 are to
do a build/make. This is currently NOT supported by Raspbian and it is said to be a bit buggy.
So, in closing, all I wanted was a simple position gauge that I could use easily .
This apparently is too much to ask and so I have coded using a QProgress bar and I am done with it.
There is an old saying: "Done is better than perfect."
With 50 + years of coding behind me, done is very attractive.
When and if I can ever get to v6 on this platform, I will reconsider learning/using creator.
Thank you again for your assistance and patience with this (and me). -
@bobd
For the links you could find the older Qt5 ones. I think things still worked the same way.OK, now I get that Thonny is just the Python editor you happen to be using. You create
.ui
files with Qt Designer, it's not integrated into Thonny. You write Python code which callsloadUi()
to load the.py
.ui
at runtime.You would have needed and could have used the Python version of that qscale example. You would have had to use their
qsacle.py
file or whatever it was in your own code. I think they ended up providing a.ui
for it or a custom widget or you could have created it and put it on your window. But somebody might have had to show you how to use it!In any case, using a Qt-supplied widget like a
QProgressBar
is going to be an awful lot easier and fit in/work just like all the other Qt-supplied widgets you are currently using in Designer to produce your.ui
file without complications.