Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. What is difference between QColor("transparent") and QColor(Qt::transparent)
Qt 6.11 is out! See what's new in the release blog

What is difference between QColor("transparent") and QColor(Qt::transparent)

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 3 Posters 19.8k 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.
  • VRoninV Offline
    VRoninV Offline
    VRonin
    wrote on last edited by
    #2
    qDebug() << "Qt::black" << QString::number(QColor(Qt::black).rgba(),16);
    qDebug() << "transparent" << QString::number(QColor("transparent").rgba(),16);
    qDebug() << "Qt::transparent" << QString::number(QColor(Qt::transparent).rgba(),16);
    qDebug() << "Qt::black==transparent" << (QColor(Qt::black) == QColor("transparent"));
    

    result:

    Qt::black "ff000000"
    transparent "0"
    Qt::transparent "0"
    Qt::black==transparent false
    

    So:

    What is difference between QColor("transparent") and QColor(Qt::transparent)

    none

    Why QColor(Qt::black) == QColor("transparent")

    They are not

    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
    ~Napoleon Bonaparte

    On a crusade to banish setIndexWidget() from the holy land of Qt

    Q 1 Reply Last reply
    3
    • Q Offline
      Q Offline
      Qt Enthusiast
      wrote on last edited by
      #3
      This post is deleted!
      1 Reply Last reply
      0
      • VRoninV VRonin
        qDebug() << "Qt::black" << QString::number(QColor(Qt::black).rgba(),16);
        qDebug() << "transparent" << QString::number(QColor("transparent").rgba(),16);
        qDebug() << "Qt::transparent" << QString::number(QColor(Qt::transparent).rgba(),16);
        qDebug() << "Qt::black==transparent" << (QColor(Qt::black) == QColor("transparent"));
        

        result:

        Qt::black "ff000000"
        transparent "0"
        Qt::transparent "0"
        Qt::black==transparent false
        

        So:

        What is difference between QColor("transparent") and QColor(Qt::transparent)

        none

        Why QColor(Qt::black) == QColor("transparent")

        They are not

        Q Offline
        Q Offline
        Qt Enthusiast
        wrote on last edited by
        #4

        @VRonin

        In 4.3.3 , I am getting following output
        qDebug() << "Qt::black==transparent" << (QColor(Qt::black) == QColor("transparent"));

        it is true

        qDebug() << "Qt::transparent==transparent" << (QColor(Qt::transparent) == QColor("transparent")

        as false

        can u check

        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by VRonin
          #5

          That's probably because named colours did not support transparency until Qt 5.2, see https://bugreports.qt.io/browse/QTBUG-6725

          QColor("transparent") in Qt 4 is actually fully opaque with RGB components all set to 0, in other words black

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          2
          • Q Offline
            Q Offline
            Qt Enthusiast
            wrote on last edited by
            #6

            Can I consider to be bug of Qt.4.3.3

            mrjjM 1 Reply Last reply
            0
            • VRoninV Offline
              VRoninV Offline
              VRonin
              wrote on last edited by
              #7

              not a bug, a feature

              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
              ~Napoleon Bonaparte

              On a crusade to banish setIndexWidget() from the holy land of Qt

              1 Reply Last reply
              4
              • Q Qt Enthusiast

                Can I consider to be bug of Qt.4.3.3

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by mrjj
                #8

                @Qt-Enthusiast
                Its not a bug. Its just how it worked back then. :)
                You are using a very old Qt that is no longer maintained or change so in this case
                its just how it was implemented back then. They later change it to support transparent in # syntax but
                its not in your version.

                1 Reply Last reply
                1
                • Q Offline
                  Q Offline
                  Qt Enthusiast
                  wrote on last edited by
                  #9

                  What is signification of alpha value ?

                  QColor sc("transparent")

                  sc.alpha() is 255 for for qt.4.3.3
                  and
                  sc.alpha() is 0 after Qt 5.2

                  What is sc.alpha means

                  mrjjM VRoninV 2 Replies Last reply
                  0
                  • Q Qt Enthusiast

                    What is signification of alpha value ?

                    QColor sc("transparent")

                    sc.alpha() is 255 for for qt.4.3.3
                    and
                    sc.alpha() is 0 after Qt 5.2

                    What is sc.alpha means

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by mrjj
                    #10

                    @Qt-Enthusiast
                    alpha is the transparency level

                    1 Reply Last reply
                    3
                    • Q Qt Enthusiast

                      What is signification of alpha value ?

                      QColor sc("transparent")

                      sc.alpha() is 255 for for qt.4.3.3
                      and
                      sc.alpha() is 0 after Qt 5.2

                      What is sc.alpha means

                      VRoninV Offline
                      VRoninV Offline
                      VRonin
                      wrote on last edited by
                      #11

                      @Qt-Enthusiast said in What is difference between QColor("transparent") and QColor(Qt::transparent):

                      What is signification of alpha value ?

                      https://en.wikipedia.org/wiki/Alpha_compositing#Alpha_blending

                      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                      ~Napoleon Bonaparte

                      On a crusade to banish setIndexWidget() from the holy land of Qt

                      1 Reply Last reply
                      3

                      • Login

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