CassioTC
25th March 2011, 16:57
Hi,
I'm trying create a animated menu, i'ts a simple animation, just show and hide the menu.
But I get a error and can't figure that out
Menu *menu = new Menu();
menu->setPos(0, scene->sceneRect().center().y() - (menu->boundingRect().center().y()*scaleT));
scene->addItem(menu);
setScene(scene);
j->setPos(350,0);
i->setPos(400,0);
QPushButton *button = new QPushButton;
//animaçao menu
QStateMachine machine;
QState *state_hide = new QState(&machine);
QState *state_show = new QState(&machine);
machine.setInitialState(state_show);
state_show->assignProperty(menu, "pos", QPointF(110,200));
state_hide->assignProperty(menu, "pos", QPointF(800,200));
QAbstractTransition *t1 = state_show->addTransition(button, SIGNAL(clicked()),state_hide);
QSequentialAnimationGroup *animation1SubGroup = new QSequentialAnimationGroup;
animation1SubGroup->addPause(250);
t1->addAnimation(animation1SubGroup);
t1->addAnimation(new QPropertyAnimation(menu, "pos"));
QAbstractTransition *t2 = state_hide->addTransition(button, SIGNAL(clicked()), state_show);
t2->addAnimation(new QPropertyAnimation(menu, "pos"));
machine.start();
class Menu: public QGraphicsRectItem
{
public:
Menu();
protected:
void paint( QPainter *, const QStyleOptionGraphicsItem *option, QWidget *widget );
void mousePressEvent(QGraphicsSceneMouseEvent *event);
private:
QImage *menu_image;
};
Menu::Menu()
{
visible = false;
menu_image = new QImage("C:/menu.png");
setRect(0, 0, menu_image->width(), menu_image->height());
setFlag(ItemIsMovable);
float itemScale = (float) QApplication::desktop()->width() / (float)1920;
this->setScale(itemScale);
Botao *button1 = new Botao(QImage("C:/botao.png"), QImage("C:/botao2.png"), "Iluminação Terreo");
button1->setParentItem(this);
button1->setPos(0,226);
}
Errors:
mainview.cpp:67: error: no matching function for call to 'QState::assignProperty(Menu*&, const char [4], QPointF)'
../src/corelib/statemachine/qstate.h:94: note: candidates are: void QState::assignProperty(QObject*, const char*, const QVariant&)
mainview.cpp:69: error: no matching function for call to 'QState::assignProperty(Menu*&, const char [4], QPointF)'
../src/corelib/statemachine/qstate.h:94: note: candidates are: void QState::assignProperty(QObject*, const char*, const QVariant&)
mainview.cpp:76: error: no matching function for call to 'QPropertyAnimation::QPropertyAnimation(Menu*&, const char [4])'
../src/corelib/animation/qpropertyanimation.h:79: note: candidates are: QPropertyAnimation::QPropertyAnimation(const QPropertyAnimation&)
../src/corelib/animation/qpropertyanimation.h:64: note: QPropertyAnimation::QPropertyAnimation(QObject*, const QByteArray&, QObject*)
../src/corelib/animation/qpropertyanimation.h:63: note: QPropertyAnimation::QPropertyAnimation(QObject*)
mainview.cpp:79: error: no matching function for call to 'QPropertyAnimation::QPropertyAnimation(Menu*&, const char [4])'
../src/corelib/animation/qpropertyanimation.h:79: note: candidates are: QPropertyAnimation::QPropertyAnimation(const QPropertyAnimation&)
../src/corelib/animation/qpropertyanimation.h:64: note: QPropertyAnimation::QPropertyAnimation(QObject*, const QByteArray&, QObject*)
../src/corelib/animation/qpropertyanimation.h:63: note: QPropertyAnimation::QPropertyAnimation(QObject*)
I'm trying create a animated menu, i'ts a simple animation, just show and hide the menu.
But I get a error and can't figure that out
Menu *menu = new Menu();
menu->setPos(0, scene->sceneRect().center().y() - (menu->boundingRect().center().y()*scaleT));
scene->addItem(menu);
setScene(scene);
j->setPos(350,0);
i->setPos(400,0);
QPushButton *button = new QPushButton;
//animaçao menu
QStateMachine machine;
QState *state_hide = new QState(&machine);
QState *state_show = new QState(&machine);
machine.setInitialState(state_show);
state_show->assignProperty(menu, "pos", QPointF(110,200));
state_hide->assignProperty(menu, "pos", QPointF(800,200));
QAbstractTransition *t1 = state_show->addTransition(button, SIGNAL(clicked()),state_hide);
QSequentialAnimationGroup *animation1SubGroup = new QSequentialAnimationGroup;
animation1SubGroup->addPause(250);
t1->addAnimation(animation1SubGroup);
t1->addAnimation(new QPropertyAnimation(menu, "pos"));
QAbstractTransition *t2 = state_hide->addTransition(button, SIGNAL(clicked()), state_show);
t2->addAnimation(new QPropertyAnimation(menu, "pos"));
machine.start();
class Menu: public QGraphicsRectItem
{
public:
Menu();
protected:
void paint( QPainter *, const QStyleOptionGraphicsItem *option, QWidget *widget );
void mousePressEvent(QGraphicsSceneMouseEvent *event);
private:
QImage *menu_image;
};
Menu::Menu()
{
visible = false;
menu_image = new QImage("C:/menu.png");
setRect(0, 0, menu_image->width(), menu_image->height());
setFlag(ItemIsMovable);
float itemScale = (float) QApplication::desktop()->width() / (float)1920;
this->setScale(itemScale);
Botao *button1 = new Botao(QImage("C:/botao.png"), QImage("C:/botao2.png"), "Iluminação Terreo");
button1->setParentItem(this);
button1->setPos(0,226);
}
Errors:
mainview.cpp:67: error: no matching function for call to 'QState::assignProperty(Menu*&, const char [4], QPointF)'
../src/corelib/statemachine/qstate.h:94: note: candidates are: void QState::assignProperty(QObject*, const char*, const QVariant&)
mainview.cpp:69: error: no matching function for call to 'QState::assignProperty(Menu*&, const char [4], QPointF)'
../src/corelib/statemachine/qstate.h:94: note: candidates are: void QState::assignProperty(QObject*, const char*, const QVariant&)
mainview.cpp:76: error: no matching function for call to 'QPropertyAnimation::QPropertyAnimation(Menu*&, const char [4])'
../src/corelib/animation/qpropertyanimation.h:79: note: candidates are: QPropertyAnimation::QPropertyAnimation(const QPropertyAnimation&)
../src/corelib/animation/qpropertyanimation.h:64: note: QPropertyAnimation::QPropertyAnimation(QObject*, const QByteArray&, QObject*)
../src/corelib/animation/qpropertyanimation.h:63: note: QPropertyAnimation::QPropertyAnimation(QObject*)
mainview.cpp:79: error: no matching function for call to 'QPropertyAnimation::QPropertyAnimation(Menu*&, const char [4])'
../src/corelib/animation/qpropertyanimation.h:79: note: candidates are: QPropertyAnimation::QPropertyAnimation(const QPropertyAnimation&)
../src/corelib/animation/qpropertyanimation.h:64: note: QPropertyAnimation::QPropertyAnimation(QObject*, const QByteArray&, QObject*)
../src/corelib/animation/qpropertyanimation.h:63: note: QPropertyAnimation::QPropertyAnimation(QObject*)