[Qt-interest] ugly QGraphicsTexItem when it is zoomed
changwon lee
bosscq at nexgeo.com
Mon Sep 20 11:23:05 CEST 2010
Thank you for sample.
but it didn't solve problem.
I found some bugs in Qt font.
http://bugreports.qt.nokia.com/browse/QTBUG-12677
http://bugreports.qt.nokia.com/browse/QTBUG-205
It describes that font hint before zoom is used when zoom. so spacing
between character is ugly.
It is pity that we don't know when this problem can be corrected.
regards
On 2010-09-18 오전 1:48, Constantin Makshin wrote:
> I suggest you to use QGraphicsView::setTransform().
>
> As an example of zooming feature, here is the related code from my application (FlowchartView is a subclass of QGraphicsView):
>
> void FlowchartView::setScale (qreal scale)
> {
> // Get the point the view is currently centered at
> QPointF viewCenter = mapToScene(rect().center());
>
> // Scale the view
> setTransform(QTransform::fromScale(scale, scale));
>
> // Restore old view position
> centerOn(viewCenter);
> }
>
> void FlowchartView::setScale (int percentage)
> {
> setScale(qreal(percentage) / 100.0f);
> }
>
> On Friday 17 September 2010 06:14:10 changwon lee wrote:
>> thank you for answer.
>>
>> but I zoomed view by view api like this.
>>
>> void MainWindow::sceneScaleChanged(const QString&scale)
>> {
>> //double newScale = scale.left(scale.indexOf(tr("%"))).toDouble() /
>> 100.0; //I have modified original source code. to use any scale factor.
>> double newScale = scale.toDouble();
>> QMatrix oldMatrix = view->matrix();
>> view->resetMatrix();
>> view->translate(oldMatrix.dx(), oldMatrix.dy());
>> view->scale(newScale, newScale);
>> }
>>
>> just added QGraphicsTextItem (font size1.5) to scene
>> and scaled using above code.
>>
>> is this method wrong? (this is example of Qt)
>>
>> regards
>>
>> On 2010-09-17 오전 5:00, Jason H wrote:
>>> Agreed. Don't handle zoom yourself, let Qt do that.
>>>
>>>
>>>
>>>
>>> ----- Original Message ----
>>> From: Constantin Makshin<cmakshin at gmail.com>
>>> To: Qt Interest<qt-interest at trolltech.com>
>>> Sent: Thu, September 16, 2010 2:17:25 PM
>>> Subject: Re: [Qt-interest] ugly QGraphicsTexItem when it is zoomed
>>>
>>> Have you tried QGraphicsTextItem::setTextWidth()?
>>>
>>> And don't scale/zoom by doing everything (move and resize items, etc.) yourself
>>> — you're likely to get better results by using QGraphicsView::setTransform().
>>>
>>> On Thursday 16 September 2010 18:37:11 changwon lee wrote:
>>>> Hello
>>>>
>>>> I have attached two pictures.
>>>> These are the result of modified DiagramScene Example.
>>>>
>>>> I have modified two part.
>>>> one is font size and another is scale;
>>>> I used float font size and can change scale freely.
>>>>
>>>> change_font_size_fix_scale image looks good.
>>>> it's font size is 48.5 and no scale is applied.
>>>>
>>>> fix_font_size_change_scale image looks bad.
>>>> I have set font size 1.5 and magnified x37.
>>>>
>>>> I want to define font size as scene coordinate. if I change scale, text
>>>> changes with other objects in scene.
>>>> This is similar to adding text in CAD. User define text size as length
>>>> in drawing coordinate system.
>>>> but it seems that my assumption is not true.
>>>>
>>>> Do I have to change font size when scale changes?
>>>>
>>>> regards
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list