Setting default color for brush
-
do you mean QBrush? Because it's not clear whats the base class type of "paint".
QBrush has an "constructor":http://qt-project.org/doc/qt-4.8/qbrush.html#QBrush-3 which accepts a QColor as parameter.
-
It's QPainter .
-
ok but a QPainter doesn't have a method called setPenColor(). So i guess you have implemented it?!
If so it should be analog for the brush. -
I created that function:
void paint::setPenColor(const QColor &newColor)
//! [5] //! [6]
{
myPenColor = newColor;
}Parts declared in paint.h header file{
void setPenColor(const QColor &newColor);QColor myPenColor;}
These are the extra info. related to the function
-
Any help now? How to set the default color for the pen?
-
QPainter::setPen(QColor) and QPainter::setBrush(QColor)
but i don't know what you actually are doing. :)
you defined the method as
@paint::setPenColor(const QColor &newColor)@
but using it as
@painter->setPenColor(255,255,255);@This can't work.
-
okay...so what should I do?
-
use the 2 QPainter methods i've posted.
and as i said, the code you've posted isn't clear to me, so i can't help you with the information you have posted so far.
-
hmm...okay...so like I have to choose the white color. How to use the setpen method?
what's the exact code for that...
(sorry for asking the exact thing...usually i would have worked it out, but i have to show this in half an hour...so, i think u can understand the desperation) :P -
@
painter; //your QPainter instancepainter->setPen( QColor(Qt::white) );
painter->setBrush( QColor(Qt::white) );
@good luck!
-
thanks...;)
-
okay..I implemented what you said.
But now it shows these errors:
invalid use of incomplete type 'struct ImageViewer'
&
forward declaration of 'struct ImageViewer'before this it didn't show these...what's the problem?
-
post the complete code please of the affected class/file.
-
hey..no need just found out the problem.
just slight error.
Thanks...it works :) -
good to hear.
-
thanks...:)