How would you set a custom color using RBG values to a QBrush? And then draw a rectangle with the brush on a GraphicsView.
So far I've tried:
QBrush *goldBrush = new QBrush(QColor(212,175,55));
scene->addRect(0,415,20,50,noPen,goldBrush);
The error message is:
error: C2664: 'QGraphicsRectItem *QGraphicsScene::addRect(qreal,qreal,qreal,qreal,const QPen &,const QBrush &)' : cannot convert argument 6 from 'QBrush *' to 'const QBrush &' Reason: cannot convert from 'QBrush *' to 'const QBrush' No constructor could take the source type, or constructor overload resolution was ambiguous
Then when I replace the first line with:
const QBrush *goldBrush = new QBrush(QColor(212,175,55));
The message is only slightly changed to:
error: C2664: 'QGraphicsRectItem *QGraphicsScene::addRect(qreal,qreal,qreal,qreal,const QPen &,const QBrush &)' : cannot convert argument 6 from 'const QBrush *' to 'const QBrush &' Reason: cannot convert from 'const QBrush *' to 'const QBrush' No constructor could take the source type, or constructor overload resolution was ambiguous
You should replace "scene->addRect(0,415,20,50,noPen,goldBrush);" with "scene->addRect(0,415,20,50,noPen,*goldBrush);". The way you are doing it, you are passing an adress to a position on the memory instead of a reference to the variable.