[Qt-interest] Can QTextEdit scale in the way what QGraphicsView does?
cheng long
kevinclcn at gmail.com
Thu May 20 13:26:28 CEST 2010
Guido, I know what's wrong, I set the parent when I created the QTextEdit.
Removing the parent, it works.
QTextEdit* textEdit = new QTextEdit(__view__);
On Thu, May 20, 2010 at 7:03 PM, cheng long <kevinclcn at gmail.com> wrote:
> Embedding a Widget with QGraphicsProxyWidget
>
> There are two ways to embed a widget using QGraphicsProxyWidget. The most
> common way is to pass a widget pointer to QGraphicsScene::addWidget<http://doc.qt.nokia.com/4.6/qgraphicsscene.html#addWidget>()
> together with any relevant Qt::WindowFlags<http://doc.qt.nokia.com/4.6/qt.html#WindowType-enum>.
> This function returns a pointer to a QGraphicsProxyWidget. You can then
> choose to reparent or position either the proxy, or the embedded widget
> itself.
>
>
> The description above is copied from
> http://doc.qt.nokia.com/4.6/qgraphicsproxywidget.html
>
>
> I tried also adding QGraphicsProxyWidget by:
>
> QGraphicsProxyWidget* proxy = new QGraphicsProxyWidget();
>
> proxy->setWidget(textEdit);
>
> scene->addItem(proxy);
>
>
> But it doesn't work also, i.e. when I call view.scale(2., 2.), the textEdit
> does not scale along with it.
>
>
> -Kevin
>
> On Thu, May 20, 2010 at 5:24 PM, Guido Seifert <Wargand at gmx.de> wrote:
>
>>
>> Nope, works fine in 4.6.
>> But you just cannot add a text widget to a graphics scene.
>> To to this you need the QGraphicsProxyWidget. You find an example
>> how to do it in your qt's demo folder under 'embeddeddialogs'.
>>
>> Guido
>>
>>
>> > Does it works only in Qt 4.7? I tried but it fails to work. Codes as
>> > below:
>> > m_pWinWidget = new QWinWidget(this);
>> > QHBoxLayout* hbox = new QHBoxLayout(m_pWinWidget);
>> >
>> > QGraphicsView* view = new QGraphicsView();
>> > hbox->addWidget(view);
>> >
>> > QGraphicsScene* scene = new QGraphicsScene();
>> > view->setScene(scene);
>> >
>> > QTextEdit* textEdit = new QTextEdit(view);
>> > textEdit->setText("Hello, Qt");
>> > scene->addWidget(textEdit);
>> >
>> > hbox->setMargin(0);
>> > view->setMinimumHeight(300);
>> > view->setMinimumWidth(300);
>> > m_pWinWidget->show();
>> >
>> > Kevin
>> >
>> > On Thu, May 20, 2010 at 4:00 PM, Guido Seifert <Wargand at gmx.de> wrote:
>> >
>> > >
>> > >
>> > > I want to add: I tried this once. Worked fine. Sort of. The fonts
>> looked
>> > > very quickly very ugly.
>> > >
>> > > Guido
>> > >
>> > > -------- Original-Nachricht --------
>> > > > Datum: Thu, 20 May 2010 08:58:57 +0100
>> > > > Von: Sean Harmer <sean.harmer at maps-technology.com>
>> > > > An: qt-interest at trolltech.com
>> > > > Betreff: Re: [Qt-interest] Can QTextEdit scale in the way what
>> > > QGraphicsView does?
>> > >
>> > > > Hi,
>> > > >
>> > > > On Thursday 20 May 2010 08:47:06 cheng long wrote:
>> > > > > QGraphicsView scales its content by adjusting its transform
>> matrix,
>> > > > > very excellent!
>> > > > >
>> > > > > Is there any way to add this functionality to QTextEdit? How?
>> > > >
>> > > > You can use QGraphicsProxyWidget to add a QTextEdit to a graphics
>> view
>> > to
>> > > > enable transformations. See the example in the documentation for
>> more
>> > > > detail:
>> > > >
>> > > >
>> http://doc.qt.nokia.com/4.7-snapshot/qgraphicsproxywidget.html#details
>> > > >
>> > > > Cheers,
>> > > >
>> > > > Sean
>> > > > _______________________________________________
>> > > > Qt-interest mailing list
>> > > > Qt-interest at trolltech.com
>> > > > http://lists.trolltech.com/mailman/listinfo/qt-interest
>> > >
>> > > --
>> > > GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
>> > > Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
>> > > _______________________________________________
>> > > Qt-interest mailing list
>> > > Qt-interest at trolltech.com
>> > > http://lists.trolltech.com/mailman/listinfo/qt-interest
>> > >
>>
>> --
>> GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
>> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100520/5f2cf3d6/attachment.html
More information about the Qt-interest-old
mailing list