Results 1 to 7 of 7

Thread: Use QColor to set different color in loop

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2015
    Posts
    109
    Thanks
    20
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Use QColor to set different color in loop

    Sorry Cruz, I dont understand what do you mean by using fixed random seed ?

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,540
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Use QColor to set different color in loop

    In main() add this line :
    Qt Code:
    1. qsrand(0);
    To copy to clipboard, switch view to plain text mode 
    After this every time rand will generate this same series.
    Or don't use rand but use fixed colors for curve 1, 2, 3...

  3. The following user says thank you to Lesiok for this useful post:

    npatil15 (20th February 2019)

  4. #3
    Join Date
    Jun 2015
    Posts
    109
    Thanks
    20
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Use QColor to set different color in loop

    Thank you all Experts
    It works like charm, I have added qsrand(0) into constructor and whenever I'm using qrand it gets initialize with same color for all the number of curves
    Qt Code:
    1. QColor(qrand()%256, qrand()%256, qrand()%256)
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 4
    Last Post: 6th August 2011, 01:40
  2. change color during a loop
    By 21did21 in forum Newbie
    Replies: 2
    Last Post: 2nd July 2011, 01:13
  3. Main loop thread loop communication
    By mcsahin in forum Qt Programming
    Replies: 7
    Last Post: 25th January 2011, 16:31
  4. Replies: 12
    Last Post: 25th December 2009, 15:07
  5. Trouble: Updating color QColor and QBrush
    By SwedishPete in forum Newbie
    Replies: 3
    Last Post: 1st December 2009, 15:34

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
  •  
Qt is a trademark of The Qt Company.