[vtkusers] Adding a text widget into qvtk

Rodrigo Lovera lobo.theslayer at gmail.com
Mon Nov 26 18:52:34 EST 2012


I've just got there, issue now is i'm using something like:

this->ui->editLine->text()

to get the text into the edit line

but when I insert it sth like these
textrepresentation->SetText(this->ui->editLine->text());

gives me the following error:
2>C:\Users\RODRIGO
LOVERA\Documents\QTProjects\ProyectoTesis\GUIforUSVisualization\mainwindow.cpp(1074):
error C2664: 'vtkTextRepresentation::SetText' : cannot convert parameter 1
from 'QString' to 'const char *'
2>          No user-defined-conversion operator available that can perform
this conversion, or the operator cannot be called

you know any method to do these conversion required?

And some extra question, is there any way to collocate the comments
anywhere on the qvtkwidget just dragging them with the mouse??

Im using these code for the widget>
    this->TextWidget = vtkSmartPointer< vtkTextWidget>::New();
    this->TextWidget->SetInteractor(this->ui->vtksurface->GetInteractor());

    vtkSmartPointer< vtkTextActor > textActor =
        vtkSmartPointer<vtkTextActor >::New();
    vtkSmartPointer< vtkTextRepresentation > textRep =
        vtkSmartPointer< vtkTextRepresentation >::New();
    textRep->SetTextActor(textActor);
    textRep->SetText(this->ui->lineEdit->text());
    //textRep->SetText("Esto es una prueba");
    this->TextWidget->SetRepresentation(textRep);
    this->TextWidget->CreateDefaultRepresentation();


2012/11/26 David Doria <daviddoria at gmail.com>

> On Mon, Nov 26, 2012 at 6:16 PM, Rodrigo Lovera <lobo.theslayer at gmail.com>wrote:
>
>> Hi,
>>
>> I already know how to setup vtk/qt using the qvtkwidget and got it to
>> work the text display, well i'm using a pushButton in Qt to activate a text
>> widget which will appear on my qvtkwidget as well as my volume rendering.
>> My point now is how can I do to interactively write a commentary or some
>> annotation on it.
>>
>> I mean, I'm working with medical images and is kind of required to add
>> some labels or commentaries in some views. Is there any direct way to add
>> the textwidget and start typing whatever you want on the qvtkwidget?? or
>> maybe a way to get the text of an texteditbox from qt??? I'm really stucked
>> at this point.
>>
>>
>> Rodrigo
>
>
> You should use a QLineEdit and connect it's textChanged() signal to a slot
> that updates the vtkTextWidget and re-renders the scene:
>
> http://doc.qt.digia.com/qt/qlineedit.html#textChanged
>
> David
>



-- 
*Rodrigo aka WarHearT*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20121126/a828c7aa/attachment.htm>


More information about the vtkusers mailing list