Results 1 to 3 of 3

Thread: question with QColor

  1. #1

    Default question with QColor

    Hi, is there any kind soul that would explaine what the below source means. thanks


    Qt Code:
    1. if (nodeData.fadeNumber>255 ||nodeData.fadeNumber<0)
    2. {
    3. nodeData.fadeNumber=255;
    4. }
    5. if (nodeData.re<100)
    6. {
    7. nodeColorDark = QColor(0xD0, 0x80, 0x00,(nodeData.fadeNumber));
    8. nodeColor =QColor(0xff, 0xff, 0x00,(nodeData.fadeNumber));
    9. }
    10. else
    11. {
    12. nodeColor = QColor(0x00, 0xf0, 0xff,(nodeData.fadeNumber));
    13. nodeColorDark =QColor(0x00, 0x00, 0xff,(nodeData.fadeNumber));
    14. }
    15. break;
    16. default :
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: question with QColor

    fire up qt assistant and go to qcolor
    QColor::QColor ( int r, int g, int b, int a = 255 )
    Constructs a color with the RGB value r, g, b, and the alpha-channel (transparency) value of a.
    The color is left invalid if any of the arguments are invalid.
    See also setRgba() and isValid().

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: question with QColor

    Qt Code:
    1. if (nodeData.fadeNumber>255 ||nodeData.fadeNumber<0)
    2. {
    3. nodeData.fadeNumber=255;
    4. }
    To copy to clipboard, switch view to plain text mode 
    This checks if the value of nodeData.fadeNumber is between 0 and 255.
    Qt Code:
    1. if (nodeData.re<100)
    2. {
    3. nodeColorDark = QColor(0xD0, 0x80, 0x00,(nodeData.fadeNumber));
    4. nodeColor =QColor(0xff, 0xff, 0x00,(nodeData.fadeNumber));
    5. }
    6. else
    7. {
    8. nodeColor = QColor(0x00, 0xf0, 0xff,(nodeData.fadeNumber));
    9. nodeColorDark =QColor(0x00, 0x00, 0xff,(nodeData.fadeNumber));
    10. }
    To copy to clipboard, switch view to plain text mode 
    Depending if nodeData.fadeNumber is lower 100 or bigger some colors are set. No problem.

    But I think you are wondering about 0x00 or 0xFF. That are simple hexadecimal notations for 0 or 255...

    Please also note our Newbie section.

Similar Threads

  1. SQL Question
    By ^NyAw^ in forum Qt Programming
    Replies: 5
    Last Post: 8th April 2008, 19:36
  2. QColor with style sheets
    By tommy in forum Qt Programming
    Replies: 4
    Last Post: 27th December 2007, 05:37
  3. MFC PALLETEINDEX to QColor()
    By maverick_pol in forum Qt Programming
    Replies: 8
    Last Post: 24th September 2007, 07:10
  4. QThread exit()/quit() question
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 28th August 2006, 14: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.