title: Fill function in basic graphics app in Qt
body: <p>I have been creating a basic graphics program(like MS Paint) with simple GUI. I have two classes where one is a MainWindow which holds all buttons, sliders etc and a second class is a custom widget called drawingArea on which a user is able to draw. 
  Basicly I've implemented most of functions, but unfortunetly I stucked at filling function, which should work just like one in MS Paint. I decided to use so called floodFill algorithm and after few hours of fighting(I am a beginner in Qt) I have managed to make it work. But not at all. The problem is I am only able to fill black-colored regions(shapes, lines, points etc) with the color I choose. But when it comes to filling different colors, it just puts one pixel in chosen color. In funcion fill(...) below I am passing  two arguments - point(mouseClicked) and a color of that point. Here:</p>
  
  <pre><code>void drawingArea::fill(const QPoint &amp;point, QColor act)
  {
  QPainter painter(&amp;image);
  QPen myPen(actualColor);
  myPen.setWidth(1);
  painter.setPen(myPen);
  
  QQueue&lt;QPoint&gt; pixels;
  pixels.enqueue(point);
  while(pixels.isEmpty() == 0)
  {
      QPoint newPoint = pixels.dequeue();
      QColor actual;
      actual.fromRgb(image.pixel(newPoint));
          if(actual == act)
          {
             painter.drawPoint(newPoint);
             update();
  
             QPoint left((newPoint.x()-1), newPoint.y());
             if(left.x() &gt;0 &amp;&amp; left.x() &lt; image.width() &amp;&amp; image.pixel(left) == act.rgb())
             {
                 pixels.enqueue(left);
                 painter.drawPoint(left);
                 update();
             }
  
             QPoint right((newPoint.x()+1), newPoint.y());
             if(right.x() &gt; 0 &amp;&amp; right.x() &lt; image.width() &amp;&amp; image.pixel(right) == act.rgb())
             {
                 pixels.enqueue(right);
                 painter.drawPoint(right);
                 update();
             }
  
             QPoint up((newPoint.x()), (newPoint.y()-1));
             if(up.y() &gt; 0 &amp;&amp; up.y() &lt; image.height() &amp;&amp; image.pixel(up) == act.rgb())
             {
                 pixels.enqueue(up);
                 painter.drawPoint(up);
                 update();
             }
  
             QPoint down((newPoint.x()), (newPoint.y()+1));
             if(down.y() &gt; 0 &amp;&amp; down.y() &lt; image.height() &amp;&amp; image.pixel(down) == act.rgb())
             {
                 pixels.enqueue(down);
                 painter.drawPoint(down);
                 update();
             }
          }
    }
  }
  </code></pre>
  
  <p>I call this fill(...) function inside mousePressEvent here:</p>
  
  <pre><code>void drawingArea::mousePressEvent(QMouseEvent *event)
   {
   if (event-&gt;button() == Qt::LeftButton)
     {
       lastPoint = event-&gt;pos();
       QColor clr;
       clr.fromRgb(image.pixel(lastPoint));
       firstPoint = event-&gt;pos();
       isDrawing = true;
       if(isColorcheck)   colorcheck(lastPoint);
       if(isFill) fill(lastPoint,clr);
     }
   }
  </code></pre>
  
  <p>The really don't understand how it is working only on black color, when passing argument QColor of different colors.
  I would really appreciate any help or ideas.</p>