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. No fill option in QColorDialog

No fill option in QColorDialog

Scheduled Pinned Locked Moved Unsolved General and Desktop
qcolordialog
20 Posts 3 Posters 5.2k Views
  • 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.
  • Q Qt Enthusiast

    Hi all
    I am using a QColorDialog box . Can I enhance the existing qcolordialog to have no fill option . That means when the user selects the no fill option (as we have in Microsoft ppt) , and if a box is filled then it should be cleared
    and can some one suggest me no fill option

    raven-worxR Offline
    raven-worxR Offline
    raven-worx
    Moderators
    wrote on last edited by raven-worx
    #2

    @Qt-Enthusiast
    sorry - but at least to me - its absolutely not clear what you mean.
    Anyway, you only have the provided API. The only thing is that you can install event filter on the dialogs children. But their classes are all not public, so not much you can do there.

    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
    If you have a question please use the forum so others can benefit from the solution in the future

    mrjjM 1 Reply Last reply
    0
    • raven-worxR raven-worx

      @Qt-Enthusiast
      sorry - but at least to me - its absolutely not clear what you mean.
      Anyway, you only have the provided API. The only thing is that you can install event filter on the dialogs children. But their classes are all not public, so not much you can do there.

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

      @raven-worx

      I have the same feeling. :)

      I think it means a no color option.
      Instead of clicking on say red, and
      get red fill you can select empty area ( a non color) and
      get none, meaning if u had a color before, its now cleared.

      raven-worxR 1 Reply Last reply
      0
      • mrjjM mrjj

        @raven-worx

        I have the same feeling. :)

        I think it means a no color option.
        Instead of clicking on say red, and
        get red fill you can select empty area ( a non color) and
        get none, meaning if u had a color before, its now cleared.

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #4

        @mrjj
        and how is it possible to click on no color?

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        mrjjM 1 Reply Last reply
        0
        • raven-worxR raven-worx

          @mrjj
          and how is it possible to click on no color?

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

          @raven-worx
          In paint programs its often shown as clear box with cross over.
          with the other colors. And left click clears pen color and right click clear fill color.
          (tried to find image)

          :)
          (edit)
          In power point its a button

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

            When I click on the empty boxes in Custom color . it is changing to white . Am I missing something

            mrjjM 1 Reply Last reply
            0
            • mrjjM mrjj

              @raven-worx
              In paint programs its often shown as clear box with cross over.
              with the other colors. And left click clears pen color and right click clear fill color.
              (tried to find image)

              :)
              (edit)
              In power point its a button

              raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #7

              @mrjj
              ok, so meaning transparency?

              This should be somewhat possible with:

              colorDialog->setOption( QColorDialog::ShowAlphaChannel, true );
              

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              mrjjM 1 Reply Last reply
              1
              • raven-worxR raven-worx

                @mrjj
                ok, so meaning transparency?

                This should be somewhat possible with:

                colorDialog->setOption( QColorDialog::ShowAlphaChannel, true );
                
                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by mrjj
                #8

                @raven-worx
                No, it means set to no color.
                Like if for painter, then clear the fill color so it dont fill. ( is my guess :)

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

                  if i have square in QGraphicsView and if I use this no color , the fill color of box should be set to its background just like clearing the box color fill color . Am I clear or shall I send a image for the same

                  1 Reply Last reply
                  0
                  • Q Qt Enthusiast

                    When I click on the empty boxes in Custom color . it is changing to white . Am I missing something

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

                    @Qt-Enthusiast
                    Those white colors are custom colors :)
                    Its not for no color.

                    1 Reply Last reply
                    0
                    • mrjjM mrjj

                      @raven-worx
                      No, it means set to no color.
                      Like if for painter, then clear the fill color so it dont fill. ( is my guess :)

                      raven-worxR Offline
                      raven-worxR Offline
                      raven-worx
                      Moderators
                      wrote on last edited by
                      #11

                      @mrjj
                      and whats the difference between "no fill" and "transparancy" then?!

                      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                      If you have a question please use the forum so others can benefit from the solution in the future

                      mrjjM 1 Reply Last reply
                      1
                      • raven-worxR raven-worx

                        @mrjj
                        and whats the difference between "no fill" and "transparancy" then?!

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

                        @raven-worx
                        You are right,
                        its should give same effect ?

                        But im not sure user will intuitively think, "ahh
                        if i lower Alpha to zero, it get rid of fill" :)

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

                          Can someone write the code

                          mrjjM 1 Reply Last reply
                          0
                          • Q Qt Enthusiast

                            Can someone write the code

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

                            @Qt-Enthusiast
                            Hi
                            @raven-worx showed you what to add to your color dialog.
                            colorDialog->setOption( QColorDialog::ShowAlphaChannel, true );
                            Then you get Alpha value.
                            User can set to zero and you get a transparent color which should look the same as no color.

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

                              This is my code
                              can some one guide me how to do it here

                              connect(this, SIGNAL(clicked(const QModelIndex&)), this, SLOT(clickedActivated(const QModelIndex&)));
                              }

                              void myView::clickedActivated(const QModelIndex& index)
                              {
                              if (index.column() == 1 ) {
                              QColorDialog* colorDialog = new QColorDialog;
                              colorDialog->setOption(QColorDialog::ShowAlphaChannel, true );
                              QColor color = QColorDialog::getColor();
                              d_model->setData(index,color,Qt::DecorationRole);

                              }

                              as I am getting compiltation error

                              raven-worxR 1 Reply Last reply
                              0
                              • Q Qt Enthusiast

                                This is my code
                                can some one guide me how to do it here

                                connect(this, SIGNAL(clicked(const QModelIndex&)), this, SLOT(clickedActivated(const QModelIndex&)));
                                }

                                void myView::clickedActivated(const QModelIndex& index)
                                {
                                if (index.column() == 1 ) {
                                QColorDialog* colorDialog = new QColorDialog;
                                colorDialog->setOption(QColorDialog::ShowAlphaChannel, true );
                                QColor color = QColorDialog::getColor();
                                d_model->setData(index,color,Qt::DecorationRole);

                                }

                                as I am getting compiltation error

                                raven-worxR Offline
                                raven-worxR Offline
                                raven-worx
                                Moderators
                                wrote on last edited by
                                #16

                                @Qt-Enthusiast

                                QColorDialog colorDialog;
                                colorDialog.setOption(QColorDialog::ShowAlphaChannel, true );
                                colorDialog.exec();
                                QColor color = colorDialog.getColor();
                                if( color.isValid() )
                                   d_model->setData(index,color,Qt::DecorationRole);
                                

                                --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                                If you have a question please use the forum so others can benefit from the solution in the future

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

                                  I am using qt.4.3.3 I am getting following compliation error

                                  error: ?class QColorDialog? has no member named ?setOption?
                                  colorDialog.setOption(QColorDialog::ShowAlphaChannel, true );
                                  error: ?ShowAlphaChannel? is not a member of ?QColorDialog?
                                  colorDialog.setOption(QColorDialog::ShowAlphaChannel, true );

                                  my code is

                                  void myInstView::clickedActivated(const QModelIndex& index)
                                  {
                                  if (index.column() == 1 ) {
                                  QColorDialog colorDialog;
                                  colorDialog.setOption(QColorDialog::ShowAlphaChannel, true );
                                  colorDialog.exec();
                                  QColor color = colorDialog.getColor();
                                  if( color.isValid() )
                                  model->setData(index,color,Qt::DecorationRole);
                                  }

                                  }
                                  }

                                  raven-worxR 1 Reply Last reply
                                  0
                                  • Q Qt Enthusiast

                                    I am using qt.4.3.3 I am getting following compliation error

                                    error: ?class QColorDialog? has no member named ?setOption?
                                    colorDialog.setOption(QColorDialog::ShowAlphaChannel, true );
                                    error: ?ShowAlphaChannel? is not a member of ?QColorDialog?
                                    colorDialog.setOption(QColorDialog::ShowAlphaChannel, true );

                                    my code is

                                    void myInstView::clickedActivated(const QModelIndex& index)
                                    {
                                    if (index.column() == 1 ) {
                                    QColorDialog colorDialog;
                                    colorDialog.setOption(QColorDialog::ShowAlphaChannel, true );
                                    colorDialog.exec();
                                    QColor color = colorDialog.getColor();
                                    if( color.isValid() )
                                    model->setData(index,color,Qt::DecorationRole);
                                    }

                                    }
                                    }

                                    raven-worxR Offline
                                    raven-worxR Offline
                                    raven-worx
                                    Moderators
                                    wrote on last edited by
                                    #18

                                    @Qt-Enthusiast
                                    it seems it is only available since Qt 4.5

                                    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                                    If you have a question please use the forum so others can benefit from the solution in the future

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

                                      Can there be any alternative to it

                                      mrjjM 1 Reply Last reply
                                      0
                                      • Q Qt Enthusiast

                                        Can there be any alternative to it

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

                                        @Qt-Enthusiast
                                        Nope.
                                        Fast way is to make new button or menu
                                        that clear the color on the selected item.

                                        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