Results 1 to 3 of 3

Thread: change color during a loop

  1. #1
    Join Date
    May 2011
    Posts
    122
    Thanks
    34
    Platforms
    Windows

    Default change color during a loop

    Hello world,

    i have K curve on a plot and i want to change the color for each curves but i don't know how i can made this

    Me code it's here:

    Qt Code:
    1. for ( int k = 0 ; k < NbOfCurve ; ++k )
    2. {
    3. mycurve[0+k*nombreDoublePlot]->attach( myPlot1 );
    4. mycurve[0+k*nombreDoublePlot]->setStyle( QwtPlotCurve::Dots );
    5. mycurve[0+k*nombreDoublePlot]->setPen( QPen( Qt::blue, 2) );
    6. }
    To copy to clipboard, switch view to plain text mode 

    This code plots all the curve in blue, however i want differents color for each iteration

    can you help me please

  2. #2
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: change color during a loop

    So you want the call to setPen() to take a different argument each time? If that's the case, store your colors in an array and call setPen(colorArray[k],2). Or, if there are more curves than colors, call setPen(colorArray[k % numberOfColors],2).

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

    21did21 (2nd July 2011)

  4. #3
    Join Date
    May 2011
    Posts
    122
    Thanks
    34
    Platforms
    Windows

    Default Re: change color during a loop

    thank for your help, i think i will use this solution

Similar Threads

  1. Change in color map?
    By bigjoeystud in forum Qwt
    Replies: 4
    Last Post: 8th September 2010, 21:00
  2. Replies: 3
    Last Post: 22nd January 2010, 17:46
  3. Replies: 12
    Last Post: 25th December 2009, 16:07
  4. how to change backgroup color, button color and shape?
    By lzha022 in forum Qt Programming
    Replies: 10
    Last Post: 16th June 2008, 23:25
  5. [QTable] Change row's color
    By villy in forum Qt Programming
    Replies: 5
    Last Post: 15th November 2006, 20:21

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.