Results 1 to 3 of 3

Thread: How to set a QString to a previously defined codec name

  1. #1
    Join Date
    Nov 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default How to set a QString to a previously defined codec name

    Hello to all !

    The following scenario is given:

    I have a QTextEdit object added to my existing window ui file.

    The user can make write operations to that QTextEdit object.

    If this is finished, the user can press a button, to tell the pogram,
    that the text input is complete is ready to be processed further.

    The program enters the slot, whch is defined to process the button - click.

    In this slot I fill a QString variable (called txt) with the textEdits toPlainText() methode.

    This functions correctly.

    Now I have an QString variable (called codecName) , which describes
    the textcodec name, to which the QString variable has to be transformed to.

    For example, this QString codecName is initialized to "UTF-8".

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    But: It can be any other value, that describes the codec name
    which can be found onto the customer system, depending on the
    user settings.
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    I tried to get information on how to transform the QString txt, which holds
    the textEdits toPlainText() value and to transform it using the codec name
    assigend to codecName.

    Can anyone help me how to perform this operation ?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to set a QString to a previously defined codec name

    QTextCodec::codecForName(), then using QTextCodec::fromUnicode() on the returned object.

    Cheers,
    _

  3. #3
    Join Date
    Nov 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to set a QString to a previously defined codec name

    Thank you for your answer !

    It helped a lot !

Similar Threads

  1. int to QString with defined size
    By ^NyAw^ in forum Qt Programming
    Replies: 2
    Last Post: 10th February 2012, 03:44
  2. Comparing a Qstring with a value defined in an enum
    By AndresBarbaRoja in forum Newbie
    Replies: 5
    Last Post: 24th March 2011, 16:11
  3. Replies: 1
    Last Post: 2nd September 2010, 15:20
  4. Qt phonon and Codec
    By alexcuiCN in forum Qt Programming
    Replies: 2
    Last Post: 27th April 2010, 08:56
  5. Replies: 25
    Last Post: 15th January 2006, 00:53

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.