Results 1 to 5 of 5

Thread: Newbie question about special characters in QLabel

  1. #1
    Join Date
    Jun 2007
    Posts
    62
    Thanks
    28
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Newbie question about special characters in QLabel

    I'm trying to display a "registered trademark" symbol (u+00AE) in the text of a QLabel. Yes, I've read the other posts on the forum on this topic but I'm failing to implement them.

    I read the string from a database, store it in a QString, then use that to set the QLabel.setText(). The symbol appears as an open rectangle. I've used style sheets to set various font families on the QLabel and they all appear as various sized rectangles.

    So I tried turning the string from the database (theQSqlQuery->value(2).toByteArray()) into a QString by using the QString::fromUtf8() function. This makes the symbol appear as a question mark. QString::fromLocal8bit() does the same thing.

    Does anybody have suggestions as to what I am doing wrong?

    Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Newbie question about special characters in QLabel

    What is the encoding of your database?

  3. #3
    Join Date
    Jun 2007
    Posts
    62
    Thanks
    28
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Newbie question about special characters in QLabel

    Well, I hate to waste your time, but I'm not really sure of the encoding of my database.

    I'm working in a Windows XP environment. My content provider writes up the description fields of the database in Microsoft Word (in which he includes trade mark symbols, non-breaking spaces, and other characters with an ASCII value higher than 128), and cuts & pastes them into a Microsoft Excel spreadsheet. The spreadsheet is exported as a *.csv file. My Python script transforms this into an *.sql file and runs it through Sqlite3 to make the database file. The Qt app reads it in with a QSqlDatabase::addDatabase("QSQLITE", dbName[i]) statement.

    If you can have pity on a clueless newbie and tell me how to determine the encoding of my database I would be happy to do it for you.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Newbie question about special characters in QLabel

    Then most probably your encoding is broken. You have to make sure sqlite3 stores the data in UTF-8. Unfortunately the console (sqlite3) doesn't do that - it uses local encoding (latin1 most probably in your case). You have to somehow fix that. For example by filling the database using Qt.

  5. The following user says thank you to wysota for this useful post:

    WinchellChung (3rd April 2008)

  6. #5
    Join Date
    Jun 2007
    Posts
    62
    Thanks
    28
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Newbie question about special characters in QLabel

    Thanks! I'll do that.

Similar Threads

  1. Problem at time compilation in traslation of language
    By thomasjoy in forum Qt Programming
    Replies: 3
    Last Post: 22nd May 2007, 14:18

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.