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. Customizing the QColorDialog for transparency in percentage

Customizing the QColorDialog for transparency in percentage

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 4 Posters 2.5k Views 1 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.
  • P Offline
    P Offline
    Pauly
    wrote on last edited by
    #1

    In QColorDialog, I can control the transparency by giving the option ShowAlphaChannel and change the alpha from 0 to 255. I'd like to control the transparency in terms of percentage. Is there an easy way to change the QColorDialog just so that the alpha channel / transparency control to be in %? Thanks.

    jsulmJ 1 Reply Last reply
    0
    • P Pauly

      In QColorDialog, I can control the transparency by giving the option ShowAlphaChannel and change the alpha from 0 to 255. I'd like to control the transparency in terms of percentage. Is there an easy way to change the QColorDialog just so that the alpha channel / transparency control to be in %? Thanks.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Pauly 128 is 50% of 255.
      So, just calculate the alpha from percentage.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      P 1 Reply Last reply
      0
      • jsulmJ jsulm

        @Pauly 128 is 50% of 255.
        So, just calculate the alpha from percentage.

        P Offline
        P Offline
        Pauly
        wrote on last edited by
        #3

        @jsulm

        Yes, I know that. I just want to replace the alpha value of 0~255 to the percentage, in terms of the GUI input method. Can I do it without dramatic effort like rebuilding the reset of QColorDialog?

        jsulmJ 1 Reply Last reply
        0
        • P Pauly

          @jsulm

          Yes, I know that. I just want to replace the alpha value of 0~255 to the percentage, in terms of the GUI input method. Can I do it without dramatic effort like rebuilding the reset of QColorDialog?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Pauly What does "GUI input method" mean?
          What does "rebuilding the reset of QColorDialog" mean?
          Can you explain better what you want to do? Do you want the user to control the transparency?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          P 1 Reply Last reply
          0
          • jsulmJ jsulm

            @Pauly What does "GUI input method" mean?
            What does "rebuilding the reset of QColorDialog" mean?
            Can you explain better what you want to do? Do you want the user to control the transparency?

            P Offline
            P Offline
            Pauly
            wrote on last edited by
            #5

            @jsulm

            In the QColorDialog, the transparency is set by entering a value (0~255) to alpha channel input. I would like to let user enter a percentage instead. I understand I can build my own widget to do anything I want, but since I'm ok with all other functions in QColorDialog except just the alpha channel entering, building a new widget for just that seems to be a lot of effort for minimum return.

            I wonder if anyone knows a way to alter the alpha channel input so that it takes the percentage instead of value.

            jsulmJ mrjjM 2 Replies Last reply
            0
            • P Pauly

              @jsulm

              In the QColorDialog, the transparency is set by entering a value (0~255) to alpha channel input. I would like to let user enter a percentage instead. I understand I can build my own widget to do anything I want, but since I'm ok with all other functions in QColorDialog except just the alpha channel entering, building a new widget for just that seems to be a lot of effort for minimum return.

              I wonder if anyone knows a way to alter the alpha channel input so that it takes the percentage instead of value.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Pauly As far as I can see there is nothing like this in QColorDialog. Most probably you will need to write that by yourself.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • P Pauly

                @jsulm

                In the QColorDialog, the transparency is set by entering a value (0~255) to alpha channel input. I would like to let user enter a percentage instead. I understand I can build my own widget to do anything I want, but since I'm ok with all other functions in QColorDialog except just the alpha channel entering, building a new widget for just that seems to be a lot of effort for minimum return.

                I wonder if anyone knows a way to alter the alpha channel input so that it takes the percentage instead of value.

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

                @Pauly
                Hi
                In theory , if using non native dialogs ( so its widgets), you might
                be able to grab the the slider and input field and handle the % thing
                Look into
                QPushButton* button = dialog->findChild<QPushButton*>("Button name");
                ( replace button with edit type / slider type)

                That might allow it in a very hackish way.

                For anything besides a for fun project, its not a good solution to hack the existing dialogs.

                P 2 Replies Last reply
                0
                • mrjjM mrjj

                  @Pauly
                  Hi
                  In theory , if using non native dialogs ( so its widgets), you might
                  be able to grab the the slider and input field and handle the % thing
                  Look into
                  QPushButton* button = dialog->findChild<QPushButton*>("Button name");
                  ( replace button with edit type / slider type)

                  That might allow it in a very hackish way.

                  For anything besides a for fun project, its not a good solution to hack the existing dialogs.

                  P Offline
                  P Offline
                  Pauly
                  wrote on last edited by
                  #8

                  @mrjj said in Customizing the QColorDialog for transparency in percentage:

                  ght allow it in a very hackish

                  This sounds like a good idea. What is wrong with it?

                  BTW, how could I find the name of the button/edit box etc without the source code?

                  1 Reply Last reply
                  0
                  • mrjjM mrjj

                    @Pauly
                    Hi
                    In theory , if using non native dialogs ( so its widgets), you might
                    be able to grab the the slider and input field and handle the % thing
                    Look into
                    QPushButton* button = dialog->findChild<QPushButton*>("Button name");
                    ( replace button with edit type / slider type)

                    That might allow it in a very hackish way.

                    For anything besides a for fun project, its not a good solution to hack the existing dialogs.

                    P Offline
                    P Offline
                    Pauly
                    wrote on last edited by
                    #9

                    @mrjj

                    hmmm. So I try to do this to find out the spin box I want to hack in QColorDialog,

                    QColorDialog *newDialog=new QColorDialog();
                    QList<QSpinBox *> widgets = newDialog->findChildren<QSpinBox *>();
                    for (int i=0; i<widgets.size();i++) { qDebug()<<widgets[i]->objectName();}
                    

                    and I get:
                    ""
                    ""
                    ""
                    ""
                    ""
                    ""
                    ""

                    no name??? How would it work or am I missing something?

                    J.HilkJ 1 Reply Last reply
                    0
                    • P Pauly

                      @mrjj

                      hmmm. So I try to do this to find out the spin box I want to hack in QColorDialog,

                      QColorDialog *newDialog=new QColorDialog();
                      QList<QSpinBox *> widgets = newDialog->findChildren<QSpinBox *>();
                      for (int i=0; i<widgets.size();i++) { qDebug()<<widgets[i]->objectName();}
                      

                      and I get:
                      ""
                      ""
                      ""
                      ""
                      ""
                      ""
                      ""

                      no name??? How would it work or am I missing something?

                      J.HilkJ Offline
                      J.HilkJ Offline
                      J.Hilk
                      Moderators
                      wrote on last edited by
                      #10

                      @Pauly
                      take a look at the code

                      the Spinbox is created without an object name so, no luck there.

                      You could iterate over all children of the dialog, and qobect_castthem into QColSpinBox its most likly the last one in the list...


                      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                      Q: What's that?
                      A: It's blue light.
                      Q: What does it do?
                      A: It turns blue.

                      1 Reply Last reply
                      1

                      • Login

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