rachana
13th February 2007, 12:07
Hi all,
How to change the color and size of QGraphicsItem? Can somebody explain how
to change the size and color of the items when mutate menu is clicked? here is the code,
MainWindow:: MainWindow( QWidget *parent)
: QMainWindow(parent)
{
scene = new QGraphicsScene;
mango = new Mango; //instance of QGraphicsItem
apple= new Apple; //instance of QGraphicsItem
scene->addItem(mango);
scene->addItem(apple);
view = new QGraphicsView(scene); //make sure always pass the QGraphicsScene
view->setSceneRect(-400,-400,800,800);
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
mutateAct = new QAction(tr("&Mutate"),this);
connect(mutateAct, SIGNAL(triggered()), this, SLOT(mutate()));
fileMenu->addAction(mutateAct);
view->setRenderHint(QPainter::Antialiasing,true);
setCentralWidget(view);
}
void MainWindow::mutate()
{
//change the size and color of apple??
//change the size and color of mango??
}
How to change the color and size of QGraphicsItem? Can somebody explain how
to change the size and color of the items when mutate menu is clicked? here is the code,
MainWindow:: MainWindow( QWidget *parent)
: QMainWindow(parent)
{
scene = new QGraphicsScene;
mango = new Mango; //instance of QGraphicsItem
apple= new Apple; //instance of QGraphicsItem
scene->addItem(mango);
scene->addItem(apple);
view = new QGraphicsView(scene); //make sure always pass the QGraphicsScene
view->setSceneRect(-400,-400,800,800);
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
mutateAct = new QAction(tr("&Mutate"),this);
connect(mutateAct, SIGNAL(triggered()), this, SLOT(mutate()));
fileMenu->addAction(mutateAct);
view->setRenderHint(QPainter::Antialiasing,true);
setCentralWidget(view);
}
void MainWindow::mutate()
{
//change the size and color of apple??
//change the size and color of mango??
}