Results 1 to 2 of 2

Thread: How to modify text sent from one text widget to another?

  1. #1
    Join Date
    May 2014

    Default How to modify text sent from one text widget to another?

    I have been working on tutorials showing how to create applications that send text typed in one text widget to another text widget using signals and slots. I want to do that, but I want to be able to transform the text as it is sent, so that the text that appears in the target is different from what is typed in the source. For example, if I type text in one widget, I might want to transform the typed text using a Caesar cipher:
    Now is the time ...
    Klt fp qeb qfjb ...
    (Each letter is shifted three positions to the left in the order of the alphabet.).
    I want to be able to write a function that will transform the input text and add it to the code produced by, for example, Qt Creator.
    However, when I open the files it creates, it appears that all the work is being done behind the scenes by supplied code.
    I have no idea whether it is possible to modify it or how to do so.
    Can anyone shed any light on this? By that I mean, what file to modify or add, where to put it, etc.
    Thanks in advance for any suggestions.

  2. #2
    Join Date
    Mar 2009
    Brisbane, Australia
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Unix/X11 Windows
    Wiki edits

    Default Re: How to modify text sent from one text widget to another?

    Let us assume you have connected QLineEdit::textChanged() (signal) to QLineEdit::setText() (slot) to get an instant direct transfer. To change the text you need to connect the signal to a slot that does the transformation and then calls setText() (directly or indirectly) with the changed value. You can make it a custom slot in the sender class that emits a custom signal with the transformed value, or you could make it a custom slot in the receiving class that simply calls setText() after transforming the input. Where you put the transforming slot is a matter of design/choice.

Similar Threads

  1. Replies: 7
    Last Post: 5th February 2014, 12:20
  2. Replies: 1
    Last Post: 24th April 2010, 16:31
  3. How to modify the content of text file
    By grsandeep85 in forum Qt Programming
    Replies: 3
    Last Post: 31st July 2009, 11:23
  4. how to modify the text of node in xml docment?
    By GChen in forum Qt Programming
    Replies: 5
    Last Post: 26th February 2009, 11:48
  5. Replies: 1
    Last Post: 3rd September 2008, 15:16

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.