Bonjour,
J'ai 1 soucis d'utilisation de la fonction drawBackGround d'un objet QGraphicsScene avec Qt.
Je pense que j'ai un problème de compréhension C++
Voici mon code résumé à l'essentiel:
fichier mycode.h
	
	| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 
 |  
class Mycode : public QMainWindow
{
  Q_OBJECT
 
myscene           *scene;
scene = new myscene();
QPixmap pix=QPixmap::fromImage(image);
QPainter *painter=new QPainter(&pix); 
const QRectF rectangle=scene->sceneRect();
scene->drawBackground(painter,rectangle);
}; | 
 fichier mycode_myscene.h
	
	| 12
 3
 4
 5
 6
 7
 8
 
 |  
class myscene : public QGraphicsScene
{
public:
  myscene();
  ~myscene();
protected:
  virtual void drawBackground( QPainter * painter, const QRectF & rect ); | 
 fichier mycode_myscene.cpp
	
	| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 
 |  
#include <QtGui>
#include "mycode_myscene.h"
 
myscene::myscene()
{
  qDebug()<<"construction";
}
 
myscene::~myscene()
{
  qDebug()<<"destruction";
}
 
virtual void myscene::drawBackground( QPainter * painter, const QRectF & rect )
{
  qDebug()<<"acces drawbackground";
} | 
 prototype fonction dans la doc :
	
	void QGraphicsScene::drawBackground ( QPainter * painter, const QRectF & rect ) [virtual protected]
 erreur de compilation :
mycode_myscene.h:7:6: erreur: 'virtual void myscene::drawBackground(QPainter*, const QRectF&)' is protected
mycode.h:154:46: erreur: à l'intérieur du contexte
Je veux juste utiliser la fonction drawBackground.
Merci pour votre aide.
						
					
Partager