PDA

View Full Version : interactivity between forms and QTextEdit



maartenS
10th September 2008, 13:23
Hi,

I'm making a program where I use information from forms to create a QTextDocument.
So far I managed to put the result of a form ie a QComboBox in the QTextEdit, but now I want to change that text if the QComboBox changes its value. Is this possible with QTextCursor? I found an easy way to insert a block, but couldn't find an easy way to change or delete is.
Ideally I would like to 'label' a block of text (ie. block1) and then make a function to change it (ie updateBlock(block1); ).
Can anyone give me suggestions in how to achieve this?

Thanks

aamer4yu
11th September 2008, 07:24
Am not sure what u are trying to do,
but if u wan to do somethnig on combox selection changed, you can use QComboBox::currentIndexChanged

maartenS
11th September 2008, 19:22
Am not sure what u are trying to do,
but if u wan to do somethnig on combox selection changed, you can use QComboBox::currentIndexChanged

Yes I Know. I want to change the text in a block in a QDocument when the index has changed. So when I select the name of a person in a QCombobox I want to put his address in the QDocument. I've been looking through the documentation about QTextBlock and QTextCursor but still cannot find an easy solution.

jpn
12th September 2008, 16:41
Yes, QTextCursor is the right tool. The idea is that you'd first select the existing keyword and then just insert the new keyword. If the keyword is easy to identify, you can simply search for it. Otherwise you could use for example QTextBlock::userData to store necessary information to be able to identify the keyword to be replaced.

maartenS
16th September 2008, 17:10
Thanks,

I think that's what I'm looking for.
How is QTextBlock::userData() working? In the documentation was written what it can do, but not exactly how, and there are no functions in the QTextBlockUserData class.

jpn
16th September 2008, 17:41
You can subclass QTextBlockUserData and add any data members you want.