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. How to link signal of QColorDiaglog to a slot.

How to link signal of QColorDiaglog to a slot.

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 587 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.
  • S Offline
    S Offline
    summit
    wrote on last edited by summit
    #1

    This is my code where i am opening a QColor diaglog.

    I want to reflect the change of color in realtime so want to link the colorChanged signal to a function.

    How can i link currentColorChanged(const QColor &color) of QDiaglog to slot ParamChangeCurrentKeyColor.

    void Sum_ChromaKey::ParamChangeKeyColor()
    {
    	QColor color;
    	int r, g, b;
    	color = QColorDialog::getColor();  // link  currentColorChanged signal to  ParamChangeCurrentKeyColor
    	color.getRgb(&r, &g, &b);
    	_KeyColor.r = r;
    	_KeyColor.g = g;
    	_KeyColor.b = b;
    
    	// currentColorChanged(const QColor &color)
    
    }
    
    
    void Sum_ChromaKey::ParamChangeCurrentKeyColor(const QColor &color)
    {
    	_KeyColor.r = color.red;
    	_KeyColor.g = color.green;
    	_KeyColor.b = color.blue;
    }
    
    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi

      you need to create your own instance in connect to that

      QColorDialog col;
      connect(&col, &QColorDialog::currentColorChanged,this, &Sum_ChromaKey::ParamChangeCurrentKeyColor);
      col.exec();
      
      S 1 Reply Last reply
      1
      • mrjjM mrjj

        Hi

        you need to create your own instance in connect to that

        QColorDialog col;
        connect(&col, &QColorDialog::currentColorChanged,this, &Sum_ChromaKey::ParamChangeCurrentKeyColor);
        col.exec();
        
        S Offline
        S Offline
        summit
        wrote on last edited by
        #3

        @mrjj col.exec() would be a blocking function , can i do it with a non blocking function.

        mrjjM 1 Reply Last reply
        0
        • S summit

          @mrjj col.exec() would be a blocking function , can i do it with a non blocking function.

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

          @summit
          Hi
          Call open instead and then you need to use a pointer

                  QColorDialog * col = new QColorDialog();
                  col->setAttribute(Qt::WA_DeleteOnClose); // this deletes it when closed
                  connect(col, &QColorDialog::currentColorChanged,this, &MainWindow::ParamChangeCurrentKeyColor);
                  col->open();
          
          S 1 Reply Last reply
          2
          • mrjjM mrjj

            @summit
            Hi
            Call open instead and then you need to use a pointer

                    QColorDialog * col = new QColorDialog();
                    col->setAttribute(Qt::WA_DeleteOnClose); // this deletes it when closed
                    connect(col, &QColorDialog::currentColorChanged,this, &MainWindow::ParamChangeCurrentKeyColor);
                    col->open();
            
            S Offline
            S Offline
            summit
            wrote on last edited by
            #5

            @mrjj Thank you very much for your kind help.

            mrjjM 1 Reply Last reply
            1
            • S summit

              @mrjj Thank you very much for your kind help.

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

              @summit
              You are most welcome.
              Write good questions and we try the best to answer :)

              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