Results 1 to 3 of 3

Thread: Can style sheets control rich text elements?

  1. #1
    Join Date
    Feb 2009
    Location
    Lexington, KY
    Posts
    8
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Can style sheets control rich text elements?

    I would like to change all of the h1 elements in all of the QLabels in my program to be blue. Is there an easy way to do this with a style sheet?

    I tried:

    Qt Code:
    1. QLabel.H1 { color: blue }
    To copy to clipboard, switch view to plain text mode 

    and

    Qt Code:
    1. QLabel::H1 { color: blue }
    To copy to clipboard, switch view to plain text mode 

    and a few other things that I thought might work, but no luck so far.

    I am not clear from the documentation if this is something that is supported or it is just matter of bad syntax. Has anyone done this before? Is it possible to use style sheets to control the formatting of rich text elements in a QLabel? Is there a different way to get consistent formatting of particular elements within the GUI that I should be using?

  2. #2
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Can style sheets control rich text elements?

    simple way is to use tags

    QLabel *label;
    label->setText("<i><font color=blue>Ok</font></i>");

    i think we cant control font color through styleSheet ..
    "Behind every great fortune lies a crime" - Balzac

  3. #3
    Join Date
    Feb 2009
    Location
    Lexington, KY
    Posts
    8
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Can style sheets control rich text elements?

    Quote Originally Posted by wagmare View Post
    simple way is to use tags

    QLabel *label;
    label->setText("<i><font color=blue>Ok</font></i>");

    i think we cant control font color through styleSheet ..
    I can change an individual item easily that way. What I want to do is change all h1 elements in all QLabels throughout my program. HTML can do this with CSS stylesheets. Since the Qt stylesheets are based on CSS, I thought this might be possible with Qt as well.

    From the documentation, I cannot tell if what I want is unsupported or if I am just doing it the wrong way. If anyone knows how to change the style for an h1 (or other HTML) element, please let me know.

    Thanks,
    Bill.

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. QTabWidget transparent background problem
    By destroyar0 in forum Qt Programming
    Replies: 10
    Last Post: 25th June 2009, 12:19
  3. Replies: 6
    Last Post: 14th April 2009, 17:40
  4. Doubt about QTextEdit and Rich Text
    By iamjayanth in forum Qt Programming
    Replies: 1
    Last Post: 8th April 2009, 08:11
  5. Rich text in QGraphicsTextItem
    By maverick_pol in forum Qt Programming
    Replies: 3
    Last Post: 29th September 2008, 20:08

Tags for this Thread

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.