Results 1 to 6 of 6

Thread: setting text also changes color?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Knivsta, Sweden
    Posts
    153
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11
    Thanks
    30
    Thanked 13 Times in 12 Posts

    Default setting text also changes color?

    Here is a small prog that just sets a color and some text in a QTextEdit.
    (QT 4.2 on X11)

    Qt Code:
    1. #include <QApplication>
    2. #include <QTextEdit>
    3.  
    4. int main( int argc, char **argv )
    5. {
    6. QApplication app( argc, argv );
    7.  
    8. qDebug("init color: %08x", t.textColor().rgb());
    9.  
    10. t.setTextColor(0xdd9933);
    11. qDebug("after set color: %08x", t.textColor().rgb());
    12.  
    13. t.setPlainText("Some text");
    14. qDebug("after set text: %08x", t.textColor().rgb());
    15.  
    16. t.show();
    17. app.exec();
    18. return 0;
    19. }
    To copy to clipboard, switch view to plain text mode 

    The console output is:
    Qt Code:
    1. init color: ff000000
    2. after set color: ffdd9933
    3. after set text: ff000000
    To copy to clipboard, switch view to plain text mode 

    Apparently, setting the text has the side-effect of resetting the current color. Looks like a bug to me. Anyone who can interpret it as a "feature"?
    Last edited by drhex; 18th November 2006 at 10:54. Reason: reformatted to look better

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. Replies: 2
    Last Post: 23rd July 2012, 08:42
  3. Setting text color on QLabel
    By Yorma in forum Newbie
    Replies: 11
    Last Post: 15th June 2006, 07:25
  4. Replies: 1
    Last Post: 17th March 2006, 08:19
  5. Change the text color tab page
    By gtthang in forum Qt Programming
    Replies: 4
    Last Post: 18th February 2006, 17:38

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.