Solved How do I subclass QDial to show notches values ?
-
but since you already subclassed it, why not make it work 100% like u want?
Also need to be able to give list for the "tick words" etc.
So find the source and see the paitnevent
maybe its easy to modify for what u want. -
void QDial::paintEvent(QPaintEvent *)
{
QStylePainter p(this);
QStyleOptionSlider option;
initStyleOption(&option);
p.drawComplexControl(QStyle::CC_Dial, option);
}So u can just change option.rect ( check name)
and you can control the size of the dial. -
@mrjj said:
but since you already subclassed it, why not make it work 100% like u want?
Also need to be able to give list for the "tick words" etc.
So find the source and see the paitnevent
maybe its easy to modify for what u want.If I create a composite class, I don't need anymore my subclass...
Well I don't know, I'll check tomorrow if it's easy (Because i'll probably have to change another thing on a QDial => but that's another thing x) )I guess i'll update this topic tomorrow, so if someone has another idea, I take it :)
Edit for your last message : I'll check tomorrow, I go home and I can't work there :p
See you
-
before u try composite, please try adjust paint first.
So little code. -
@mrjj said:
void QDial::paintEvent(QPaintEvent *)
{
QStylePainter p(this);
QStyleOptionSlider option;
initStyleOption(&option);
p.drawComplexControl(QStyle::CC_Dial, option);
}So u can just change option.rect ( check name)
and you can control the size of the dial.I can't do "option.something" ...
-
why not?
Look in help then? -
@mrjj
Now the problem is I can extend the area and write text in the right and in the bottom of the QDial (because the QDial is drawn (good english ?!) in the left-top (0,0) ). And I don't have any idea how to change that.. I searched if there is something like the position where qt draw of something like that, but didn't find it .. --' -
hi
Not tested myself.
option.rect should control where QDial is
and the normal rect is your widget.So if u set option.rect before
p.drawComplexU should be able to move it around?
-
-
@Punt
Option has rect yes, used for the drawComplexControl call.
You own widget, also has rect, simply called rect or this->rect
which is the real area since the QDial is just painted. -
-
Hmm
so it dont use option.rect() for the tick drawing.
Strange.Alternatively
new a layout
set to your widget
New a QDial
add to layout
adjust layout margins to get room for text.
Paint the text in paintEvent.
Remove the drawComplexControl etc. -
@mrjj
In my subclass ? -
@Punt
Yes
In constructor
so it becomes a composite widget with a normal QDial inside.
You will also have to create some public signal to use from outside
since you cannot directly connect to the QDail. -
Hi
yes that seems to be possible.
https://www.dropbox.com/s/5hjry2pcb0mpsi2/myqdial.zip?dl=0
I just did it in Creator for test. Using code in
CustomDial is smarter. -
Sorry was busy...
I don't understand how to do it..
I tried, when I want to use layout() this is crashing.. I tried different things but isn't working, I'm tired of this button x) -
@Punt
Np.
Did u try test?
U must create layout first with new
and assign to ur widget
else
layout() returns null.
something like
QVBoxLayou *verticalLayout = new QVBoxLayout(this);
verticalLayout->setContentsMargins(32, 32, 32, 32);
QDial *dial = new QDial(this); ** might have this as class memeber
verticalLayout->addWidget(dial); -
@mrjj said:
@Punt
Np.
Did u try test?
U must create layout first with new
and assign to ur widget
else
layout() returns null.
something like
QVBoxLayou *verticalLayout = new QVBoxLayout(this);
verticalLayout->setContentsMargins(32, 32, 32, 32);
QDial *dial = new QDial(this); ** might have this as class memeber
verticalLayout->addWidget(dial);Ok that worked, thanks bro ! now I'll add my texts where I want :)
-
super!
You might need to surface some of the signals from the QDial to make
it do anything usefull.In this regards , please note that u -can- connect signals to signals
So you can define some new public signals and hook the new signals
to the QDial signals.
From outside u can then connect to the new signals.