Results 1 to 4 of 4

Thread: Error creating a animated menu

  1. #1
    Join Date
    Mar 2011
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Exclamation Error creating a animated menu

    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

    Qt Code:
    1. Menu *menu = new Menu();
    2.  
    3. menu->setPos(0, scene->sceneRect().center().y() - (menu->boundingRect().center().y()*scaleT));
    4.  
    5. scene->addItem(menu);
    6.  
    7. setScene(scene);
    8.  
    9. j->setPos(350,0);
    10. i->setPos(400,0);
    11.  
    12. QPushButton *button = new QPushButton;
    13.  
    14. //animaçao menu
    15. QStateMachine machine;
    16. QState *state_hide = new QState(&machine);
    17. QState *state_show = new QState(&machine);
    18. machine.setInitialState(state_show);
    19.  
    20. state_show->assignProperty(menu, "pos", QPointF(110,200));
    21.  
    22. state_hide->assignProperty(menu, "pos", QPointF(800,200));
    23.  
    24. QAbstractTransition *t1 = state_show->addTransition(button, SIGNAL(clicked()),state_hide);
    25. QSequentialAnimationGroup *animation1SubGroup = new QSequentialAnimationGroup;
    26. animation1SubGroup->addPause(250);
    27.  
    28. t1->addAnimation(animation1SubGroup);
    29. t1->addAnimation(new QPropertyAnimation(menu, "pos"));
    30.  
    31. QAbstractTransition *t2 = state_hide->addTransition(button, SIGNAL(clicked()), state_show);
    32. t2->addAnimation(new QPropertyAnimation(menu, "pos"));
    33.  
    34. machine.start();
    To copy to clipboard, switch view to plain text mode 


    Qt Code:
    1. class Menu: public QGraphicsRectItem
    2. {
    3. public:
    4. Menu();
    5.  
    6. protected:
    7. void paint( QPainter *, const QStyleOptionGraphicsItem *option, QWidget *widget );
    8. void mousePressEvent(QGraphicsSceneMouseEvent *event);
    9.  
    10. private:
    11. QImage *menu_image;
    12. };
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. Menu::Menu()
    2. {
    3. visible = false;
    4.  
    5. menu_image = new QImage("C:/menu.png");
    6. setRect(0, 0, menu_image->width(), menu_image->height());
    7. setFlag(ItemIsMovable);
    8. float itemScale = (float) QApplication::desktop()->width() / (float)1920;
    9. this->setScale(itemScale);
    10.  
    11. Botao *button1 = new Botao(QImage("C:/botao.png"), QImage("C:/botao2.png"), "Iluminação Terreo");
    12. button1->setParentItem(this);
    13.  
    14. button1->setPos(0,226);
    15. }
    To copy to clipboard, switch view to plain text mode 

    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*)
    Last edited by CassioTC; 25th March 2011 at 18:42.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Error creating a animated menu

    QGraphicsRectItem does not inherit QObject.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2011
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Error creating a animated menu

    Thanks for answer.

    I just add the QObject in the class:

    class Menu: public QObject, public QGraphicsRectItem


    Now compile with no errors, but doesn't work.
    The menu stay in the same position.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Error creating a animated menu

    Why would anything change position? Did you read the animation framework docs before trying to use it?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Closing out a animated context menu from any active screen
    By bob2oneil in forum Qt Programming
    Replies: 5
    Last Post: 25th February 2011, 17:46
  2. Error while creating a plugin for Qt
    By panpaliamahen in forum Qt Programming
    Replies: 1
    Last Post: 7th August 2010, 19:12
  3. Replies: 1
    Last Post: 19th July 2010, 11:43
  4. Error creating subclasses
    By agerlach in forum Qt Programming
    Replies: 2
    Last Post: 25th May 2010, 13:49
  5. Replies: 6
    Last Post: 5th July 2007, 02:00

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.