Customizing QDial
-
In which case you have everything you need - apart form suitable graphics assets unless your dial scale happens to be the same as in the example ;-)
It would be nice if there were a custom QDeclarativeItem that could take a range, a radius, and start/end angles and produce a dial gauge image for use in such cases. Would be a nice little project. If only I had some time ;-)
-
Hello, Im also trying to change the appearance of the dial...but I would prefer to use c++ instead qml. By the way...I tried to use #include <QtDeclarative> and the Qt creator keep saying that the file or directory is missing.
Is possible to design my own Dial and use it?
-
Did you also put:
@
QT += declarative
@
in your .pro file when you were trying to #include <QtDeclarative>?Of course it is possible to design your own dial and use that. Subclass QWidget and reimplement paintEvent(). From there, you can do the rendering of your dial to your very own design.
-
[quote author="Andre" date="1303144548"]Did you also put:
@
QT += declarative
@
in your .pro file when you were trying to #include <QtDeclarative>?Of course it is possible to design your own dial and use that. Subclass QWidget and reimplement paintEvent(). From there, you can do the rendering of your dial to your very own design.[/quote]
I think im doing as you say...
I created now a very simple code just to check if QtDeclarative is working:
im my main.cpp I have:
@
#include <QtCore>
#include <QtDeclarative>int main()
{
return 0;
}
@and in testQML.pro i have:
@
SOURCES +=
main.cpp
QT += declarative
@then I did clean all, build all...and I get QtDeclarative: file or directory missing...
"Of course it is possible to design your own dial and use that. Subclass QWidget and reimplement paintEvent(). From there, you can do the rendering of your dial to your very own design"
would you mind to explain me better how that is done? can I design it in photoshop and have a layer for the needle that is the part that I want to rotate?
Thank you
-
I installed this: http://qt.nokia.com/downloads/sdk-linux-x11-64bit-cpp
Im running Qt creater under ubuntu 10.04.
"g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_DECLARATIVE_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I../testarQMLimport -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtDeclarative -I/usr/include/qt4 -I. -I../testarQMLimport -I. -o main.o ../testarQMLimport/main.cpp" -> I dont write this...Qt creator application does it for me...
and the error: "../testarQMLimport/main.cpp:2:25: error: QtDeclarative: Ficheiro ou directoria inexistente
make: ** [main.o] Erro 1"translation of the error -> error: QtDeclarative: File or directory does not exist
make:**[main.o] Error 1 -
I would suggest that you download the latest Qt SDK 1.1 RC instead.
[quote author="elfo106" date="1303144965"][quote author="Andre" date="1303144548"]Of course it is possible to design your own dial and use that. Subclass QWidget and reimplement paintEvent(). From there, you can do the rendering of your dial to your very own design[/quote]would you mind to explain me better how that is done? can I design it in photoshop and have a layer for the needle that is the part that I want to rotate?
[/quote]
Basically, yes. You can draw the background as an image, rotate and translate the painter, and then draw the needle either as another image or manually using QPainter. Note that if you draw that way, it will obviously not adapt to the style and colors of the rest of your system. Still, perhaps it is easier to do this in QML than it is to do it as a regular widget. -
ok, I will download it and give it a try.
In which format should the images be? (png jpeg...) and for what you said I supose that I should have 2 different images, one for background and another for the needle, and not 1 image with 2 layers. Right? if I understood it right, I must be careful positioning the images on the screen...
Thank you