Results 1 to 3 of 3

Thread: Creating a string with subscript text

  1. #1
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Creating a string with subscript text

    Hi guys,

    I have to draw some simple number in the Gscene, but the fractional part of that number should be printed as subscript.
    How to create a QString containg a subscript text? For example, is it possible to create a text with subscript part and show it in the QMessageBox? I am currently looking for a solution, but maybe someone has already done it before.

    Thanks.

    Maverick

    P.S.

    I have already checked the QTextDocument(but will not work in my case)
    I could create "paint" 2 texts where one would be on the left lower part of the first one, but that this is not acceptable.

    Found the solution:


    QMEssageBox::warning(0,QString("Upper<sub>lower</sub>"),"");
    Last edited by maverick_pol; 7th November 2007 at 16:16.
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  2. #2
    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: Creating a string with subscript text

    Please correct if I'm wrong but don't QMessageBox, QLabel, QGrapicsTextItem all support rich text:
    Here's some <sub>subscripted</sub> text.
    J-P Nurmi

  3. #3
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Creating a string with subscript text

    Hi,

    I have found the answer.

    1. In the messageBox the solution is simple:
    Qt Code:
    1. QMessageBox::warning(0,QString("Upper<sub>lower</sub>"),"");
    To copy to clipboard, switch view to plain text mode 

    Analogically we can use the HTML tags in the QTextItem to format item text.

    Maverick
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. read input string --> text mode
    By eleanor in forum Qt Programming
    Replies: 1
    Last Post: 25th October 2007, 18:08
  3. creating query string from variables
    By locus in forum General Programming
    Replies: 2
    Last Post: 16th April 2007, 08:50
  4. Creating simple text editor from the eamples code
    By overcast in forum Qt Programming
    Replies: 4
    Last Post: 14th February 2007, 15:46

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.