Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Converting From Hexadecimal to QString
Forum Updated to NodeBB v4.3 + New Features

Converting From Hexadecimal to QString

Scheduled Pinned Locked Moved Unsolved Game Development
4 Posts 3 Posters 751 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BryanC
    wrote on last edited by BryanC
    #1

    Hi Guys,
    This is my first post here and I'm hoping you can help me out. 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;}
        );
    
    //seting background color
    QString varBGColour(/*What do I put here to get #000000FF*/);
    
    setStyleSheet(styleSheet.arg(varBGColour));
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You have a nice example shown in that thread.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • B Offline
        B Offline
        BryanC
        wrote on last edited by
        #3

        Thank You, :)

        kshegunovK 1 Reply Last reply
        0
        • B BryanC

          Thank You, :)

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #4

          What's the point of c here?

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved