Qt - Converting Hexadecimal To QString

0

I've a project in which I have to implement unions so I'm doing so with a packed representation and component-wise representation of a hexadecimal color. The code below will clear things up but basically I'm stuck on how to convert from the hexadecimal to a QString so that I can use it in the stylesheet. If you have any ideas I'd really appreciate your help cause I've been unable to find an answer for the past few hours.

//union
    typedef union color4bTag
        {
        unsigned int      c;    // packed representation
        struct argbTag          // component-wise representation
            {
            unsigned char b;    // (reversed for intel storage order)
            unsigned char g;
            unsigned char r;
            unsigned char a;
            } argb;
        } COLOR4B;
    

//setting color.c
    color4bTag color;
    color.c = 0x000000FF;
    

//stylesheet
    QString styleSheet(
      "QMainWindow{background-color: %1;}"
    );
    

//setting background color
    QString varBGColour(/*What do I put here to get #000000FF*/);
    setStyleSheet(styleSheet.arg(varBGColour));
c++
qt
asked on Stack Overflow Mar 13, 2021 by Paddy O'Brien • edited Mar 13, 2021 by eyllanesc

1 Answer

0

QString::number() takes a second parameter.

QString result = QString::number( nValue, 16 );
answered on Stack Overflow Mar 13, 2021 by Joseph Larson

User contributions licensed under CC BY-SA 3.0