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 color option
Forum Updated to NodeBB v4.3 + New Features

No fill color option

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 3 Posters 2.3k Views 3 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by
    #1

    I am using following files from https://github.com/liangqi/qt-solutions/tree/master/qtcolorcombobox/src

    1. qtcolorcombobox.h
    2. qtcolorcombobox.cpp

    I have to enhacnec the code for to have no fill option also . Can some one quide for that

    ? 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      its not clear what
      "no fill option "
      should do.

      1 Reply Last reply
      0
      • Q Qt Enthusiast

        I am using following files from https://github.com/liangqi/qt-solutions/tree/master/qtcolorcombobox/src

        1. qtcolorcombobox.h
        2. qtcolorcombobox.cpp

        I have to enhacnec the code for to have no fill option also . Can some one quide for that

        ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        @Qt-Enthusiast Hi! It's not clear to me what you want to achieve. Can you please explain your intentions again, maybe draw a mockup?

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

          In color dialoboxes . we also have nofill color option

          For example . I have QGrapghicscene , if I have set the fill color of objects as red and I select no fill color m, then set the color of object to background color of QGrapghicscene

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            Oh, I see. I don't think you need extra code for this. Just insert a completely transparent color together with the text "No color" to the combobox.

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

              if you could write a code it will be helpful

              ? 1 Reply Last reply
              0
              • Q Qt Enthusiast

                if you could write a code it will be helpful

                ? Offline
                ? Offline
                A Former User
                wrote on last edited by A Former User
                #7

                @Qt-Enthusiast said:

                if you could write a code it will be helpful

                insertColor(0, QColor(0,0,0,0), tr("No color"));
                
                1 Reply Last reply
                1
                • Q Offline
                  Q Offline
                  Qt Enthusiast
                  wrote on last edited by
                  #8

                  should it be like that
                  void QtColorComboBox::insertColor(int index, const QColor &color, const QString &name)
                  {
                  QPixmap pix(12, 12);
                  QPainter painter(&pix);
                  if (color.isValid()) {
                  painter.setPen(Qt::gray);
                  painter.setBrush(QBrush(Qt::NoBrush));
                  painter.drawRect(0, 0, 12, 12);
                  }
                  QIcon icon;
                  icon.addPixmap(pix);

                  // Prevent adding of colors after the color dialog item.
                  if (colorDialogEnabled && index > colorCount()) index = colorCount() - 1;
                  insertItem(index, icon, name, color);
                  

                  }

                  QColor QtColorComboBox::color(int index) const
                  {
                  QVariant var = itemData(index);
                  // discard out of bounds requests
                  if (!var.isValid())
                  return QColor();

                  // discard requests for the "more" item
                  if (colorDialogEnabled && index == colorCount())
                      return QColor();
                  
                  return qVariantValue<QColor>(var);
                  

                  }

                  ? 1 Reply Last reply
                  0
                  • Q Qt Enthusiast

                    should it be like that
                    void QtColorComboBox::insertColor(int index, const QColor &color, const QString &name)
                    {
                    QPixmap pix(12, 12);
                    QPainter painter(&pix);
                    if (color.isValid()) {
                    painter.setPen(Qt::gray);
                    painter.setBrush(QBrush(Qt::NoBrush));
                    painter.drawRect(0, 0, 12, 12);
                    }
                    QIcon icon;
                    icon.addPixmap(pix);

                    // Prevent adding of colors after the color dialog item.
                    if (colorDialogEnabled && index > colorCount()) index = colorCount() - 1;
                    insertItem(index, icon, name, color);
                    

                    }

                    QColor QtColorComboBox::color(int index) const
                    {
                    QVariant var = itemData(index);
                    // discard out of bounds requests
                    if (!var.isValid())
                    return QColor();

                    // discard requests for the "more" item
                    if (colorDialogEnabled && index == colorCount())
                        return QColor();
                    
                    return qVariantValue<QColor>(var);
                    

                    }

                    ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by A Former User
                    #9

                    @Qt-Enthusiast said:

                    should it be like that [...]

                    You can leave the widget's sources as they are. No need to customize them. It is just a combobox which can hold a string and a colored rectangle together with some index.

                    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