+ Reply to Thread
Results 1 to 4 of 4

Thread: QLabel, large, rich text, font size

  1. #1
    Join Date
    Jan 2006
    Location
    Munich, Germany.
    Posts
    111
    Thanks
    29
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default QLabel, large, rich text, font size

    Hello....
    Really simple one ... (sorry for asking really)

    How do I get REALLY BIG text into a QLabel?

    I'm using,
    Qt Code:
    1. QString richText ("<h1><b><font color='green'> <font size=24>"+text+"</font></font></b>");
    2. setText(richText);
    3. QWidget::setFixedSize(QLabel::sizeHint());
    To copy to clipboard, switch view to plain text mode 

    Apparently, HTML can do <font size=7>, but that's not really big enough - I'd like the thing to be visible from across the room!

    I know nothing about HTML
    thanks
    K

  2. #2
    Join Date
    May 2006
    Posts
    32
    Thanks
    1
    Thanked 5 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Smile Re: QLabel, large, rich text, font size

    Hello....

    Its all magic done by html script. Try this code .. and tell me you can see the text bigger

    Qt Code:
    1. #include <QApplication>
    2. #include <QWidget>
    3. #include <QLabel>
    4. #include <QString>
    5.  
    6. int main(int argc, char **argv)
    7. {
    8. QApplication a(argc, argv);
    9.  
    10. QWidget *w = new QWidget(0);
    11. w->setWindowTitle("lokesh");
    12.  
    13. //QString ritchText("<h1><b><font color='green'> <font size=40>\"+text+\"</font></font></b>");
    14.  
    15. QString ritchText("<html><head><meta name=\"qrichtext\" content=\"1\" /></head>"
    16. "<body style=\" white-space: pre-wrap; font-family:Sans Serif; "
    17. "font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;\">"
    18. "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; "
    19. "margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:200pt;\">Qt Centre</p>"
    20. "</body></html>");
    21.  
    22.  
    23. QLabel *label = new QLabel(w);
    24. label->setText(ritchText);
    25.  
    26. w->setFixedSize(label->sizeHint());
    27.  
    28. w->show();
    29. return a.exec();
    30. }
    To copy to clipboard, switch view to plain text mode 

    You can increase / decrease this
    Qt Code:
    1. font-size:200pt;
    To copy to clipboard, switch view to plain text mode 

    Cheers
    Last edited by jacek; 5th February 2007 at 14:32. Reason: wrapped too long line

  3. The following 2 users say thank you to sarode for this useful post:

    FireMan (14th June 2008), TheKedge (5th February 2007)

  4. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany.
    Posts
    111
    Thanks
    29
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QLabel, large, rich text, font size

    Huge text!

    wow, that's a lot of html for a bit of black! nice one. thanks

    Q: is that a lot for my label to process? or is it done in nanoseconds?


    K

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

    Default Re: QLabel, large, rich text, font size

    There's no need to use HTML if you don't want to:
    Qt Code:
    1. QLabel* label = new QLabel("Qt Centre");
    2. QFont font = label->font();
    3. font.setPointSize(72);
    4. label->setFont(font);
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  6. The following 2 users say thank you to jpn for this useful post:

    FireMan (14th June 2008), TheKedge (5th February 2007)

+ Reply to Thread

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. Replies: 3
    Last Post: 30th January 2007, 07:35
  3. Replies: 1
    Last Post: 24th October 2006, 16:40
  4. QTreeView font size not being set
    By forrestfsu in forum Qt Tools
    Replies: 2
    Last Post: 12th October 2006, 13:53
  5. Setting text color on QLabel
    By Yorma in forum Newbie
    Replies: 11
    Last Post: 15th June 2006, 07:25

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