Results 1 to 6 of 6

Thread: interactivity between forms and QTextEdit

  1. #1
    Join Date
    Sep 2008
    Posts
    17
    Thanks
    4
    Thanked 5 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default interactivity between forms and QTextEdit

    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

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: interactivity between forms and QTextEdit

    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

  3. #3
    Join Date
    Sep 2008
    Posts
    17
    Thanks
    4
    Thanked 5 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: interactivity between forms and QTextEdit

    Quote Originally Posted by aamer4yu View Post
    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.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: interactivity between forms and QTextEdit

    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.
    J-P Nurmi

  5. #5
    Join Date
    Sep 2008
    Posts
    17
    Thanks
    4
    Thanked 5 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: interactivity between forms and QTextEdit

    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.

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: interactivity between forms and QTextEdit

    You can subclass QTextBlockUserData and add any data members you want.
    J-P Nurmi

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.