Results 1 to 9 of 9

Thread: MFC PALLETEINDEX to QColor()

  1. #1
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default MFC PALLETEINDEX to QColor()

    Hi guys,

    I have to convert a PALLETEINDEX(int value) which returns COLORREF. Haveing the "value" I have to create a QCOlor object.

    Can't find which PALLETEINDEX(value) return which color?
    ANyone know how to create a QColor having PalleteIndex(value)(int MFC application)

    Thanks
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: MFC PALLETEINDEX to QColor()

    MSDN:
    COLORREF value has the following hexadecimal form: 0x00bbggrr

    To extract the individual values for the red, green, and blue components of a color value, use the GetRValue, GetGValue, and GetBValue macros, respectively.
    Qt docs:
    typedef QRgb
    An ARGB quadruplet on the format #AARRGGBB, equivalent to an unsigned int.
    They seem to be in a slightly different format so you can't pass COLORREF as QRgb, but something like this should do the trick:
    Qt Code:
    1. COLORREF ref = PALETTEINDEX(n);
    2. QColor color = QColor::fromRgb(GetRValue(ref), GetGValue(ref), GetBValue(ref));
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. #3
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: MFC PALLETEINDEX to QColor()

    Hi,

    Thank you for the hint. My application is only using Qt libraries, but I also have an MFC application which I have to convert to Qt.
    Howto get the COLOREF in Qt?
    I need to find which color represents the PALLETEINDEX(int) in Qt.
    ANy other ideas howto do this. I can't use COLORREF in Qt.

    Thank you in advance.

    Maverick
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: MFC PALLETEINDEX to QColor()

    Where does the palette index come from? Are you writing something portable?
    J-P Nurmi

  5. #5
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: MFC PALLETEINDEX to QColor()

    Hi,

    Yes it is intended to be portable, there are some sets of colors and they have their RBG values. But the programmer who written the old application used some #define color1 int_value
    and than create QPEN(...,...,...PALLETEINDEX(color1)); etc

    Is it possible to use the "color1" and create a QColor from it ?

    Maverick
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  6. #6
    Join Date
    Aug 2007
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default hi to all

    can anybody tell me how to begin with QT Programmering.
    I m new to this Technology.

  7. #7
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: MFC PALLETEINDEX to QColor()

    Start a new thread or read docs first.

    Do not write non-related posts in this thread.

    Thanks
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  8. #8
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: MFC PALLETEINDEX to QColor()

    Quote Originally Posted by maverick_pol View Post
    But the programmer who written the old application used some #define color1 int_value
    and than create QPEN(...,...,...PALLETEINDEX(color1)); etc

    Is it possible to use the "color1" and create a QColor from it ?
    Try:
    Qt Code:
    1. QColor color = QColormap::instance().colorAt(color1));
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  9. The following user says thank you to jpn for this useful post:

    maverick_pol (24th September 2007)

  10. #9
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: MFC PALLETEINDEX to QColor()

    Hi,

    I will test the code today in the afternoon. Thank you for your advice. If anything come up(any errors) I will renew this thread.

    Thanks
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

Similar Threads

  1. RGB values greater than 8bit & QColor?
    By smacchia in forum Newbie
    Replies: 11
    Last Post: 21st March 2007, 14:40

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.