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 include .txt on Qt
Forum Updated to NodeBB v4.3 + New Features

How to include .txt on Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
196 Posts 11 Posters 135.9k 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.
  • K Offline
    K Offline
    KzR69100
    wrote on 19 Nov 2016, 12:47 last edited by
    #18

    @SGaist i don't know it depends as i said, but in all case i think it will contain like 50 squares.

    @mrjj Thanks for your help.
    I don't understand the " QMap<QRgb, CostInfo > Costs "

    and my problem i think, it's if i got a QColor(105,4,85) there will be a problem because it will not found a QColor who corresponds.

    So i thought use a "for" to take a value range, and have all possible color, that's correct ?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 19 Nov 2016, 19:45 last edited by
      #19
      • I don't understand the " QMap<QRgb, CostInfo > Costs "
        Its a associative list. Using QRgb ( the color ) as key and it returns a Costs struct that is the
        data associated with that key.
        Read about it here
        http://doc.qt.io/qt-5/qmap.html
        Its a lookup list so to speak.

      • and my problem i think, it's if i got a QColor(105,4,85) there will be a problem because it will not found a QColor who corresponds.

      Well if not in list, { QColor(105,4,85).rgb(), { "xxxx", 50 }},
      then nothing happens as you test with
      if (Costs.contains( col.rgb() )) { << test if found
      xxxonly do if foundxxx

      1 Reply Last reply
      0
      • K Offline
        K Offline
        KzR69100
        wrote on 19 Nov 2016, 19:56 last edited by
        #20

        @mrjj
        So if nothing happens that's bad :p

        What do you think about use a "for" ?

        Like i don't care if it's a dark red, or a simple red etc..

        My question is :

        If nothing if found, how function can i use to find the "closer" color to the define color in my struct ?

        thanks

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 19 Nov 2016, 20:21 last edited by mrjj
          #21
          • If nothing if found, how function can i use to find the "closer" color to the define color in my struct ?

          Hi
          use the QMapIterator instead of "for"

          QMapIterator<QString, int> i(map);
          while (i.hasNext()) {
          i.next();
          cout << i.key() << ": " << i.value() << endl;
          }
          http://doc.qt.io/qt-5/qmap.html#details

          That allows you to go over all and get the keys. (i.key())
          QColor TheColor(i.key())
          Then you can calculate if the RGB values for TheColor is
          close enough for you to accept it.
          For inspiration see here
          http://stackoverflow.com/questions/9018016/how-to-compare-two-colors

          int diffRed   = Math.abs(c1.getRed()   - c2.getRed());
          int diffGreen = Math.abs(c1.getGreen() - c2.getGreen());
          int diffBlue  = Math.abs(c1.getBlue()  - c2.getBlue());
          Those values you can just divide by the amount of difference saturations (255), and you will get the difference between the two.
          
          float pctDiffRed   = (float)diffRed   / 255;
          float pctDiffGreen = (float)diffGreen / 255;
          float pctDiffBlue   = (float)diffBlue  / 255;
          After which you can just find the average color difference in percentage.
          
          (pctDiffRed + pctDiffGreen + pctDiffBlue) / 3 * 100
          
          1 Reply Last reply
          0
          • K Offline
            K Offline
            KzR69100
            wrote on 19 Nov 2016, 20:42 last edited by KzR69100
            #22

            That is very complicated.

            QMap is a kind of database, a dictionary that is right ?

            I will try with you'r first code :

            I don't understand the function void Test.

            I got a function who return me a color in QRGB, it named "color" can i say just :

            If (color == (the color in the Qmap (i dont know how to call it))){
            cost = 50;
            image = (red image)
            }
            ?

            The problem is that i understand QMap, but i don't know how to use it and i'm new to programmation

            M 1 Reply Last reply 19 Nov 2016, 20:53
            0
            • K KzR69100
              19 Nov 2016, 20:42

              That is very complicated.

              QMap is a kind of database, a dictionary that is right ?

              I will try with you'r first code :

              I don't understand the function void Test.

              I got a function who return me a color in QRGB, it named "color" can i say just :

              If (color == (the color in the Qmap (i dont know how to call it))){
              cost = 50;
              image = (red image)
              }
              ?

              The problem is that i understand QMap, but i don't know how to use it and i'm new to programmation

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 19 Nov 2016, 20:53 last edited by mrjj
              #23

              @KzR69100 said in How to include .txt on Qt:

              • That is very complicated.
                Ok, its plain c++ and maps are often used. I didnt mean to make it
                complicated. Using say a DataBase would be 10 times the code.

              QMap is a kind of database, a dictionary that is right ?
              Yes. You tell it ( whatkey, whatvalue)
              and then u can ask for it to return the value for a key.
              In this sample we used a color as key.

              I don't understand the function void Test.

              void Test() {
                // this is the color to look for
                QColor col = QColor(100, 100, 100); // getColor()..
               // check the map if it has the color ( suing contains)
                if (Costs.contains( col.rgb() )) {
                  CostInfo& ci = Costs[col.rgb()]; // take the struct from list
                  qDebug() << "found:" << "cost:" << ci.Cost << "img:" << ci.ImageName;
                }
              }
              
              > 
              > I got a function who return me a color in QRGB, it named "color" can i say just :
              > If (color == (the color in the Qmap (i dont know how to call it))){
              You cannot use == you must use Contains function.
              if (Costs.contains( color.rgb() )   ) {
                  CostInfo& ci = Costs[color.rgb()]; // take the struct from list
                 QColor TheColor(i.key()); // this is the base color
                 int Cost=ci.Cost; // use the values.
                }
              
              1 Reply Last reply
              0
              • K Offline
                K Offline
                KzR69100
                wrote on 19 Nov 2016, 21:41 last edited by KzR69100
                #24
                void Test() {
                  // this is the color to look for
                  QColor col = QColor(100, 100, 100); // getColor()..
                 // check the map if it has the color ( suing contains)
                  if (Costs.contains( col.rgb() )) {
                    CostInfo& ci = Costs[col.rgb()]; // take the struct from list
                    qDebug() << "found:" << "cost:" << ci.Cost << "img:" << ci.ImageName;
                  }
                }
                

                So the QColor col is my returned color that is right ?

                i don't understand the "CostInfo& ci"

                And do the size of the picture in the Qmap have to be resized?

                PS :
                my function is :

                for(int x = topLeft.x(); x < maxX; ++x) {
                		for(int y = topLeft.y(); y < maxY; ++y) {
                			image.setPixelColor(x, y, colour);
                                                              if (Costs.contains( colour.rgb() )) {          // it will be that ?
                                                                   CostInfo& ci = Costs[colour.rgb()];
                		}
                	}
                }
                

                to have all RGB in my struct can i use a "for" (sorry to always say "can i use a for") but the problem is that i want all RGB value with my 15 - 20 pictures

                M 1 Reply Last reply 20 Nov 2016, 07:42
                0
                • K KzR69100
                  19 Nov 2016, 21:41
                  void Test() {
                    // this is the color to look for
                    QColor col = QColor(100, 100, 100); // getColor()..
                   // check the map if it has the color ( suing contains)
                    if (Costs.contains( col.rgb() )) {
                      CostInfo& ci = Costs[col.rgb()]; // take the struct from list
                      qDebug() << "found:" << "cost:" << ci.Cost << "img:" << ci.ImageName;
                    }
                  }
                  

                  So the QColor col is my returned color that is right ?

                  i don't understand the "CostInfo& ci"

                  And do the size of the picture in the Qmap have to be resized?

                  PS :
                  my function is :

                  for(int x = topLeft.x(); x < maxX; ++x) {
                  		for(int y = topLeft.y(); y < maxY; ++y) {
                  			image.setPixelColor(x, y, colour);
                                                                if (Costs.contains( colour.rgb() )) {          // it will be that ?
                                                                     CostInfo& ci = Costs[colour.rgb()];
                  		}
                  	}
                  }
                  

                  to have all RGB in my struct can i use a "for" (sorry to always say "can i use a for") but the problem is that i want all RGB value with my 15 - 20 pictures

                  M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 20 Nov 2016, 07:42 last edited by mrjj
                  #25

                  @KzR69100

                  • So the QColor col is my returned color that is right ?
                    Yes, the Color to look for.

                  • i don't understand the "CostInfo& ci"

                  It means a reference to a CostInfo.
                  We ask the map to return the CostInfo for the key and instead of
                  having it as a copy we actually point to the one in the list.
                  so if you do

                  ci.Cost = 100; you would update the one in the list.

                  if we did
                  CostInfo ci = Costs[col.rgb()];
                  It would make a copy and ci would be a copy and not point to one in the list.

                  So if it was integers and a normal list.
                  int a= List[1]; // copy
                  int &a = List[1]; // a points to the int in index [1]

                  • And do the size of the picture in the Qmap have to be resized?

                  The qmap only store the file names of the images
                  I assume you are adding the images to a QRes file
                  http://www.bogotobogo.com/Qt/Qt5_Resource_Files.php
                  So all images are build into the program
                  and then load them with ":/" syntax.
                  That would be easy and fast.
                  http://doc.qt.io/qt-5/resources.html

                  
                  for(int x = topLeft.x(); x < maxX; ++x) {
                  		for(int y = topLeft.y(); y < maxY; ++y) {
                  			image.setPixelColor(x, y, colour);
                                                                if (Costs.contains( colour.rgb() )) {          // it will be that ?  YES
                                                                     CostInfo& ci = Costs[colour.rgb()];
                                                                       int Cost = ci.Cost;
                                                                        Pixmap pix( ci.ImageName ); 
                  		}  
                  	}
                  }
                  

                  to have all RGB in my struct can i use a "for" (sorry to always say "can i use a for") but the problem is that i want all RGB value with my 15 - 20 pictures

                  Not sure what you are asking here :)
                  Are you asking how to use a FOR with the QMAP `?
                  u can do

                  
                  QMapIterator<QRgb, CostInfo >i(Costs);
                  while (i.hasNext()) {
                      i.next();
                      cout << i.key() << ": " << i.value().Cost << endl;
                  }
                  

                  Pleases read
                  http://doc.qt.io/qt-5/qmap.html

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    KzR69100
                    wrote on 20 Nov 2016, 12:12 last edited by KzR69100
                    #26

                    thanks,

                    i already read the doc for Qmap,

                    my question was the same as before (sorry) i asked that if i got a square who have a color like ( 255 , 2 , 2 - It's near red ) how can i display a red file because on my Qmap i have only

                    QColor(250,0,0).rgb(), { "C:\Users\David\Desktop\Red\strawberry", 10) (i will use :/ after created my QRes file)

                    the i.hasNext is the answer to my question right ? he will found a value next to his value ?

                    My other question was that i have to browse all my picture with a double for (because i got 50 square in my picture)

                    so i have to put the

                    if (Costs.contains( colour.rgb() )) {          
                                                                      CostInfo& ci = Costs[colour.rgb()];
                                                                        int Cost = ci.Cost;
                                                                         Pixmap pix( ci.ImageName );
                    

                    and then the while (i.hasNext()) ?

                    M 1 Reply Last reply 20 Nov 2016, 12:24
                    0
                    • K KzR69100
                      20 Nov 2016, 12:12

                      thanks,

                      i already read the doc for Qmap,

                      my question was the same as before (sorry) i asked that if i got a square who have a color like ( 255 , 2 , 2 - It's near red ) how can i display a red file because on my Qmap i have only

                      QColor(250,0,0).rgb(), { "C:\Users\David\Desktop\Red\strawberry", 10) (i will use :/ after created my QRes file)

                      the i.hasNext is the answer to my question right ? he will found a value next to his value ?

                      My other question was that i have to browse all my picture with a double for (because i got 50 square in my picture)

                      so i have to put the

                      if (Costs.contains( colour.rgb() )) {          
                                                                        CostInfo& ci = Costs[colour.rgb()];
                                                                          int Cost = ci.Cost;
                                                                           Pixmap pix( ci.ImageName );
                      

                      and then the while (i.hasNext()) ?

                      M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 20 Nov 2016, 12:24 last edited by mrjj
                      #27

                      @KzR69100

                      • my question was the same as before (sorry) i asked that if i got a square who have a color like ( 255 , 2 , 2 - It's near red )

                      For that you need to a function that can compare the RGB values.
                      And if Base Color and the color you come with ( from image) is
                      within some threshold you also accept it.
                      http://stackoverflow.com/questions/9018016/how-to-compare-two-colors
                      like
                      bool IsCloseColor( QColor c1, QColor c2 ) {
                      // this you must fill in . read link.
                      }
                      If you want a clever mathcing , this is also interresting
                      http://stackoverflow.com/questions/2103368/color-logic-algorithm

                      • the i.hasNext is the answer to my question right ? he will found a value next to his value ?
                        Yes the code shown will go over map. Just like a "For"
                        Something like:
                        QMapIterator<QRgb, CostInfo >i(Costs);
                        while (i.hasNext()) {
                          i.next();
                          QColor BaseColor( i.key() );
                          if (Costs.contains( colour.rgb() ) || IsCloseColor(BaseColor, colour)   )  {
                            CostInfo& ci = Costs[colour.rgb()];
                            int Cost = ci.Cost;
                            QPixmap pix( ci.ImageName );
                          }
                        }// while
                      
                      1 Reply Last reply
                      0
                      • K Offline
                        K Offline
                        KzR69100
                        wrote on 20 Nov 2016, 12:46 last edited by KzR69100
                        #28

                        i got :

                        bool IsCloseColor( QColor c1, QColor c2 ) {
                        	int diffRed   = Math.abs(c1.red() - c2.red());
                        	int diffGreen = Math.abs(c1.green() - c2.green());
                        	int diffBlue  = Math.abs(c1.blue()  - c2.blue());
                        
                        	if (diffBlue+diffRed+diffGreen< z){	// i block for the z how can i say "the smallest" ?
                        		return c1;
                        
                        
                        	}
                        }
                        

                        i got a lot of errors, i tried to google it but no answer :

                        like : request for meme "key in 'i'", which is of non-class type 'int'

                        template argument 2 is invalid (QMap<QRgb, CostInfo ">" Costs =)

                        scalar object 'Costs' requires one element in initializer

                        M 1 Reply Last reply 20 Nov 2016, 18:12
                        0
                        • K KzR69100
                          20 Nov 2016, 12:46

                          i got :

                          bool IsCloseColor( QColor c1, QColor c2 ) {
                          	int diffRed   = Math.abs(c1.red() - c2.red());
                          	int diffGreen = Math.abs(c1.green() - c2.green());
                          	int diffBlue  = Math.abs(c1.blue()  - c2.blue());
                          
                          	if (diffBlue+diffRed+diffGreen< z){	// i block for the z how can i say "the smallest" ?
                          		return c1;
                          
                          
                          	}
                          }
                          

                          i got a lot of errors, i tried to google it but no answer :

                          like : request for meme "key in 'i'", which is of non-class type 'int'

                          template argument 2 is invalid (QMap<QRgb, CostInfo ">" Costs =)

                          scalar object 'Costs' requires one element in initializer

                          M Offline
                          M Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on 20 Nov 2016, 18:12 last edited by
                          #29

                          @KzR69100

                          z you must decide for.
                          Best is to test with different colors and see how close its still ok.

                          With the exact code and the exact line it's impossible to say what error comes from.

                          You can try my test project. It compiles and you can test the color matching.
                          https://www.dropbox.com/s/6mc3e4qe375qzih/mylookup.zip?dl=0

                          1 Reply Last reply
                          1
                          • K Offline
                            K Offline
                            KzR69100
                            wrote on 20 Nov 2016, 19:24 last edited by KzR69100
                            #30

                            My code is : (cpp)

                            #include "mainwindow.h"
                            #include "ui_mainwindow.h"
                            #include <QPixmap>
                            #include <QImage>
                            #include <QFileDialog>
                            #include <QColor>
                            #include <QPoint>
                            #include <QSize>
                            #include <iostream>
                            using namespace std;
                            
                            
                            QColor Couleurdominante(const QImage& image, const QPoint& topLeft, const QSize& rectSize);
                            void Remplissage(QImage& image, const QPoint& topLeft, const QSize& rectSize, const QColor& colour);
                            
                            
                            MainWindow::MainWindow(QWidget *parent) :
                            	QMainWindow(parent),
                            	ui(new Ui::MainWindow)
                            {
                            		ui->setupUi(this);
                            
                            }
                            
                            
                            MainWindow::~MainWindow()
                            {
                            	delete ui;
                            }
                            
                            
                            
                            
                            void MainWindow::on_push_clicked()
                            {
                            	QString fileName = QFileDialog::getOpenFileName(this,
                            	tr("Open Image"), "/", tr("Image Files (*.png *.jpg *.bmp)"));
                            	QPixmap pix(fileName);
                            	ui->label->setPixmap(pix);
                            	const QSize s = pix.size();
                            	pixi = QImage(pix.toImage());
                            
                            	ui->label_2->setText( "Size: " + QString::number(s.width()) +" "+ QString::number(s.height()) );
                            
                            }
                            
                            void MainWindow::on_push2_clicked()
                            {
                            
                            
                            	for (int i=0;i<pixi.width();i+=a){
                            						 for (int j=0;j<pixi.height();j+=b){
                            	Remplissage(pixi,QPoint(i,j),QSize(a,b),Couleurdominante(pixi,QPoint(i,j),QSize(a,b)));
                            	}}
                            
                            	pixa=QPixmap::fromImage(pixi);
                            	ui->label_3->setPixmap(pixa);
                            
                            }
                            
                            
                            
                            
                            void Remplissage(QImage& image, const QPoint& topLeft, const QSize& rectangle, const QColor& colour) {
                            
                            	int maxX = topLeft.x() + rectangle.width();
                            	int maxY = topLeft.y() + rectangle.height();
                            
                            	for(int x = topLeft.x(); x < maxX; ++x) {
                            		for(int y = topLeft.y(); y < maxY; ++y) {
                            			image.setPixelColor(x, y, colour);
                            			QMapIterator<QRgb, CostInfo >i;
                            			while (i.hasNext()) {
                            				i.next();
                            				QColor BaseColor( i.key() );
                            				if (Costs.contains( colour.rgb() ) || IsCloseColor(BaseColor, colour) )  {
                            					CostInfo& ci = Costs[colour.rgb()];
                            					int Cost = ci.Cost;
                            					QPixmap pix( ci.ImageName );
                            				}
                            			}
                            		}
                            	}
                            }
                            
                            
                            QColor Couleurdominante(const QImage & image,const QPoint & topLeft, const QSize & rectangle)
                            {
                            		int rouge = 0, vert = 0, bleue = 0;
                            
                            		int  X = topLeft.x() + rectangle.width();
                            		int  Y = topLeft.y() + rectangle.height();
                            
                            		for (int y = topLeft.y(); y < Y; y++)  {
                            				for (int x = topLeft.x(); x < X; x++)   {
                            						QRgb pixel = image.pixel(x, y);
                            
                            						rouge += qRed(pixel);
                            						vert += qGreen(pixel);
                            						bleue += qBlue(pixel);
                            				}
                            		}
                            
                            		int n = rectangle.width() * rectangle.height();
                            
                            		Q_ASSERT(n);
                            		if (n <= 0)
                            				return Qt::black;
                            
                            		return QColor(rouge / n, vert / n, bleue / n);
                            }
                            
                            
                            
                            QMap<QRgb, CostInfo > Costs = {
                            	{ QColor(255 , 0 , 0 ).rgb(), { "://fraise.png", 10 }},
                            	{ QColor(0 , 255 , 0 ).rgb(), { "://balleverte.png", 20 }},
                            	{ QColor(0 , 0 , 255 ).rgb(), { "://ballebleue.png", 20 }},
                            	{ QColor(255 , 255 , 255 ).rgb(), { "://balleblanche.png", 20 }},
                            	{ QColor(255 , 128 , 0 ).rgb(), { "://ballepeche.png", 20 }},
                            	{ QColor(0 , 0 , 0 ).rgb(), { "://noir.png", 20 }},
                            	{ QColor(102 , 51 , 0 ).rgb(), { "://marron.png", 20 }},
                            	{ QColor(255 , 102 , 78 ).rgb(), { "://rose.png", 20 }},
                            	{ QColor(0 , 204 , 204 ).rgb(), { "://turquoise.png", 20 }},
                            	{ QColor(255 , 178 , 102 ).rgb(), { "://beige.png", 20 }},
                            	{ QColor(76 , 0 , 153 ).rgb(), { "://violet.png", 20 }},
                            	{ QColor(100 , 100 , 100 ).rgb(), { "://gris.png", 20 }},
                            };
                            
                            bool IsCloseColor( QColor c1, QColor c2 ) {
                            	int diffRed   = Math.abs(c1.red() - c2.red());
                            	int diffGreen = Math.abs(c1.green() - c2.green());
                            	int diffBlue  = Math.abs(c1.blue()  - c2.blue());
                            
                            	if (diffBlue+diffRed+diffGreen< 100){	/
                            		return c1;
                            
                            
                            	}
                            }
                            
                            
                            

                            i took z = 100. For the moment

                            .h :

                            #ifndef MAINWINDOW_H
                            #define MAINWINDOW_H
                            
                            #include <QMainWindow>
                            #include <QPixmap>
                            #include <QPoint>
                            #include <QSize>
                            #include <iostream>
                            
                            namespace Ui {
                            	class MainWindow;
                            }
                            
                            class MainWindow : public QMainWindow
                            {
                            	Q_OBJECT
                            
                            public:
                            	explicit MainWindow(QWidget *parent = 0);
                            
                            
                            	~MainWindow();
                            
                            
                            
                            
                            
                            private slots:
                            	void on_push_clicked();
                            	struct CostInfo {
                            		QString ImageName;
                            		int Cost;
                            	};
                            
                            	void on_push2_clicked();
                            
                            	void on_verticalSlider_sliderMoved(int position);
                            
                            private:
                            	Ui::MainWindow *ui;
                            	QImage pixi;
                            	QPixmap pixa;
                            	int a;
                            	int b;
                            };
                            
                            #endif // MAINWINDOW_H
                            
                            1 Reply Last reply
                            0
                            • M Offline
                              M Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on 20 Nov 2016, 22:13 last edited by
                              #31

                              Hi
                              In your
                              bool IsCloseColor( QColor c1, QColor c2 ) {
                              int diffRed = Math.abs(c1.red() - c2.red());
                              int diffGreen = Math.abs(c1.green() - c2.green());
                              int diffBlue = Math.abs(c1.blue() - c2.blue());

                              if (diffBlue+diffRed+diffGreen< 100){	/
                              	return c1; <<<<<< you should return true
                                  else //////////////////you need this part also
                                     return false;  /////////
                              
                              1 Reply Last reply
                              0
                              • K Offline
                                K Offline
                                KzR69100
                                wrote on 21 Nov 2016, 08:18 last edited by KzR69100
                                #32

                                Thank you i corrected.

                                And for my other error ?

                                in : if (Costs.contains( colour.rgb() ) || IsCloseColor(BaseColor, colour) )

                                for the function IsCloseColor, its not better to return a color ? like QColor IsCloseColor();, i don't understand what we can do if we return "false" or "true"

                                1 Reply Last reply
                                0
                                • P Offline
                                  P Offline
                                  Payx
                                  wrote on 3 Dec 2016, 16:05 last edited by
                                  #33

                                  i up ! need help ^^

                                  1 Reply Last reply
                                  0
                                  • P Offline
                                    P Offline
                                    Payx
                                    wrote on 7 Dec 2016, 12:46 last edited by
                                    #34

                                    for the function IsCloseColor, its not better to return a color ? like QColor IsCloseColor();, i don't understand what we can do if we return "false" or "true"

                                    M 1 Reply Last reply 7 Dec 2016, 12:50
                                    0
                                    • P Payx
                                      7 Dec 2016, 12:46

                                      for the function IsCloseColor, its not better to return a color ? like QColor IsCloseColor();, i don't understand what we can do if we return "false" or "true"

                                      M Offline
                                      M Offline
                                      mrjj
                                      Lifetime Qt Champion
                                      wrote on 7 Dec 2016, 12:50 last edited by
                                      #35

                                      @Payx

                                      It just checks if the color is "close " to base color
                                      No reason to return color ?
                                      we say
                                      if (Costs.contains( colour.rgb() ) || IsCloseColor(BaseColor, colour) )

                                      So if we have direct match OR
                                      the colour is close to BaseColor then we think its ok.

                                      1 Reply Last reply
                                      1
                                      • P Offline
                                        P Offline
                                        Payx
                                        wrote on 21 Dec 2016, 14:06 last edited by Payx
                                        #36

                                        Okay thank you,

                                        i have

                                        diffBlue+diffRed+diffGreen< 100
                                        

                                        but if many colors correspond ?
                                        it can return many colors no ?

                                        M 1 Reply Last reply 21 Dec 2016, 14:19
                                        0
                                        • P Payx
                                          21 Dec 2016, 14:06

                                          Okay thank you,

                                          i have

                                          diffBlue+diffRed+diffGreen< 100
                                          

                                          but if many colors correspond ?
                                          it can return many colors no ?

                                          M Offline
                                          M Offline
                                          mrjj
                                          Lifetime Qt Champion
                                          wrote on 21 Dec 2016, 14:19 last edited by mrjj
                                          #37

                                          @Payx
                                          No it cant..
                                          IsCloseColor tells if 2 colors are close. It return true/false.
                                          it dont return any color. it tells you if they color u have "in the hand" matches the
                                          base color given.
                                          You already have the color (colour var) so no reason to return it.

                                          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