Results 1 to 17 of 17

Thread: animation problem (run automatically )

  1. #1
    Join Date
    Apr 2012
    Posts
    101
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1

    Default animation problem (run automatically )

    Hi
    i make animation but it run automatically (when i run my programme it run )

    that's the function of animation
    Qt Code:
    1. bool OgreWidget::frameRenderingQueued(const Ogre::FrameEvent &evt){
    2. if (mDirection == Ogre::Vector3::ZERO)
    3. {
    4. if (nextLocation())
    5. {
    6.  
    7. }
    8. }
    9. else
    10. {
    11. Ogre::Real move = mWalkSpeed * evt.timeSinceLastFrame;
    12. animat(move);
    13.  
    14. }
    15. return true;
    16.  
    17. }
    18. void OgreWidget::animat(Ogre::Real move)
    19. {
    20. mDistance -= move;
    21. if (mDistance <= 0.0f)
    22. {
    23. mNode->setPosition(mDestination);
    24. mDirection = Ogre::Vector3::ZERO;
    25. // Set animation based on if the robot has another point to walk to.
    26. if (! nextLocation())
    27. {
    28.  
    29. }
    30. else
    31. {
    32. // Rotation Code will go here later
    33. }
    34. }
    35. else
    36. {
    37. mNode->translate(mDirection * move);
    38. } // else
    39. } // if
    To copy to clipboard, switch view to plain text mode 

    i make animat as slot
    and in my maniwondow i make like that
    Qt Code:
    1. repo_cam = new QToolButton(this);
    2. Move->setObjectName(QString::fromUtf8("Move"));
    3. Move->setGeometry(QRect(150, 10, 51, 31));
    4. connect(Move, SIGNAL(clicked()), mOgreWidget, SLOT( animat(Ogre::Real move)));
    To copy to clipboard, switch view to plain text mode 
    But with this code when i clic on the button the animation do not run and run automatically

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3
    Thanked 127 Times in 126 Posts

    Default Re: animation problem (run automatically )

    Is your question really 'why doesn't my slot get called?' Haven't we been over providing simple compilable examples for BASIC problems like signal/slot connection?

    I think I have previously informed you that you cannot connect signals to slots where the slot has more arguments. If you had bothered to debug your own code, you would have seen error message when trying to do this
    Qt Code:
    1. connect(Move, SIGNAL(clicked()), mOgreWidget, SLOT( animat(Ogre::Real move)));
    To copy to clipboard, switch view to plain text mode 

    Why don't you get used to the debugger and start trying to put the smallest of effort into solving your problems before asking for help at every opportunity?

    As an aside, does your code really look like this?
    Qt Code:
    1. bool OgreWidget::frameRenderingQueued(const Ogre::FrameEvent &evt){
    2. if (mDirection == Ogre::Vector3::ZERO)
    3. {
    4. if (nextLocation())
    5. {
    6.  
    7. }
    8. }
    9. else
    10. {
    11. Ogre::Real move = mWalkSpeed * evt.timeSinceLastFrame;
    12. animat(move);
    13.  
    14. }
    15. return true;
    16.  
    17. }
    To copy to clipboard, switch view to plain text mode 

    Why aren't you indenting consistently? Why are you indenting so much?
    Last edited by amleto; 10th June 2012 at 11:57.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #3
    Join Date
    Apr 2012
    Posts
    101
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1

    Default Re: animation problem (run automatically )

    Qt Code:
    1. bool OgreWidget::frameRenderingQueued(const Ogre::FrameEvent &evt){
    2. if (mDirection == Ogre::Vector3::ZERO)
    3. {
    4. if (nextLocation())
    5. {
    6.  
    7. }
    8. }
    9. else
    10. {
    11. Ogre::Real move = mWalkSpeed * evt.timeSinceLastFrame;
    12. animat(move);
    13.  
    14. }
    15. return true;
    16.  
    17. }
    To copy to clipboard, switch view to plain text mode 
    yes it is like that , i make simple animation if it work i will add code in the
    Qt Code:
    1. if (nextLocation())
    2. {
    3.  
    4. }
    To copy to clipboard, switch view to plain text mode 
    that's it

    i make now like that
    Qt Code:
    1. connect(Move, SIGNAL(clicked()), mOgreWidget, SLOT( animat()));
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. bool OgreWidget::frameRenderingQueued(const Ogre::FrameEvent &evt){
    2. if (mDirection == Ogre::Vector3::ZERO)
    3. {
    4. if (nextLocation())
    5. {
    6.  
    7. }
    8. }
    9. else
    10. {
    11. move = mWalkSpeed * evt.timeSinceLastFrame;
    12. animat();
    13.  
    14. }
    15. return true;
    16.  
    17. }
    18. void OgreWidget::animat()
    19. {
    20. mDistance -= move;
    21. if (mDistance <= 0.0f)
    22. {
    23. mNode->setPosition(mDestination);
    24. mDirection = Ogre::Vector3::ZERO;
    25. // Set animation based on if the robot has another point to walk to.
    26. if (! nextLocation())
    27. {
    28.  
    29. }
    30. else
    31. {
    32. // Rotation Code will go here later
    33. }
    34. }
    35. else
    36. {
    37. mNode->translate(mDirection * move);
    38. } // else
    39. } // if
    To copy to clipboard, switch view to plain text mode 
    But it still work automatically

  4. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3
    Thanked 127 Times in 126 Posts

    Default Re: animation problem (run automatically )

    "But it still work automatically"
    please explain more.


    And why did you take all formatting out of your code?
    The code tags are to make reading code easier. Therefore it doesnt help if you post code like where brace indentation doesnt match, or where there is no indentation at all.
    Last edited by amleto; 10th June 2012 at 14:10.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  5. #5
    Join Date
    Apr 2012
    Posts
    101
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1

    Default Re: animation problem (run automatically )

    "But it still work automatically"
    please explain more.
    the animation still run when i run my application not when i clic on the buttons
    Qt Code:
    1. And why did you take all formatting out of your code?
    To copy to clipboard, switch view to plain text mode 
    i explained to you why it is empty code in "if", "else"
    i do not put any code even in my application her (i cut past the code of the fuction "void QOgreWidget::animat()" )
    i want just make simple animation if it work i will add code in "if" test (i do not just delete those test to not forget what i must to do)

    you can understand now why the code of animat () is like that ?

  6. #6
    Join Date
    Sep 2011
    Posts
    1,241
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3
    Thanked 127 Times in 126 Posts

    Default Re: animation problem (run automatically )

    "And why did you take all formatting out of your code?"
    I asked why you removed *formatting*, not why you have empty code blocks.

    If you want to know why your code is being run, just USE YOUR DEBUGGER and look at call stack.


    Do you know how to use your debugger? Because it seems you don't like to use it very much...
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  7. #7
    Join Date
    Apr 2012
    Posts
    101
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1

    Default Re: animation problem (run automatically )

    I asked why you removed *formatting*, not why you have empty code blocks.
    i do not put any code to remove it i just add the "if" to do not forget that i must put this test when i will make animation more complex
    ok?

  8. #8
    Join Date
    Sep 2011
    Posts
    1,241
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3
    Thanked 127 Times in 126 Posts

    Default Re: animation problem (run automatically )

    please look up the definition of 'formatting'
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  9. #9
    Join Date
    Apr 2012
    Posts
    101
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1

    Default Re: animation problem (run automatically )

    when i debug it do not said to me any thing (like i have problem in the slot or somthing seem like error)
    it just run animat automatically

  10. #10
    Join Date
    Sep 2011
    Posts
    1,241
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3
    Thanked 127 Times in 126 Posts

    Default Re: animation problem (run automatically )

    Like I said,
    If you want to know why your code is being run, just USE YOUR DEBUGGER and look at call stack.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  11. #11
    Join Date
    Apr 2012
    Posts
    101
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1

    Default Re: animation problem (run automatically )

    Hi,
    you mean that i make preakpoint in "animat()" and see how it run ?
    if you mean that
    when i debug with (f10)
    i do not see anything strange

    what i must to see ?

  12. #12
    Join Date
    Sep 2011
    Posts
    1,241
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3
    Thanked 127 Times in 126 Posts

    Default Re: animation problem (run automatically )

    1) You said you *want* it to happen when you press button.
    2) You said it *does* happen automatically. (What do you even mean by 'automatically'?)

    So you can find out the *reason* for 2) by using your debugger.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  13. #13
    Join Date
    Apr 2012
    Posts
    101
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1

    Default Re: animation problem (run automatically )

    look at this video
    to know what i mean by automatically
    http://www.2shared.com/file/rmXc6Fs-/animvid.html

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

    Default Re: animation problem (run automatically )

    Look rimie, dreamvig or whoever you are. If you want to develop software, there is this little thing you need to do -- you need to learn. Amleto seems to be very patient with you however I'm sure his patience has its limits. You were told many times to do this or that and from my personal impression it seems you completely ignore most of the things you are told. I don't know why you do that but if you continue to behave this way, eventually nobody will want to help you anymore. You need to start investing your time in your self-improvement instead of just focusing on the functionality of your application.
    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.


  15. #15
    Join Date
    Apr 2012
    Posts
    101
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1

    Default Re: animation problem (run automatically )

    You were told many times to do this or that and from my personal impression it seems you completely ignore most of the things you are told.
    like what ?
    he told to me to change the parameter of the slot i change it
    he told to me to debug my program i debug it and i put the video

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

    Default Re: animation problem (run automatically )

    I'm really not going to argue with you about it. Take my friendly advice or not, that's your choice. Your discussion with me about using layouts is a perfect example of what I mean.
    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.


  17. #17
    Join Date
    Apr 2012
    Posts
    101
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1

    Default Re: animation problem (run automatically )

    Ok thanks for the advice


    Added after 1 57 minutes:


    i change my code littel like that
    now i can make animation only when i clic on the button
    i make like that
    Qt Code:
    1. connect(repo_cam, SIGNAL(clicked()), this, SLOT( makeanim()));
    2. void Coordinate3dWidget::makeanim()
    3. {
    4. bool istrue=true;
    5. emit newbool(istrue);
    6. }
    To copy to clipboard, switch view to plain text mode 
    and
    Qt Code:
    1. connect(page_14, SIGNAL(newbool(bool)), mQOgreWidget , SLOT(animat(bool)));
    To copy to clipboard, switch view to plain text mode 
    and in animat
    Qt Code:
    1. void QOgreWidget::animat(bool istrue)
    2. {
    3. while(istrue)
    4. {
    5. mDistance -= move;
    6. if (mDistance <= 0.0f)
    7. {
    8. mNode->setPosition(mDestination);
    9. mDirection = Ogre::Vector3::ZERO;
    10. istrue=false;
    11. // Set animation based on if the robot has another point to walk to.
    12. if (! nextLocation())
    13. {
    14. // Set Idle animation
    15. /* mAnimationState = mEntity->getAnimationState("Idle");
    16.   mAnimationState->setLoop(true);
    17.   mAnimationState->setEnabled(true);*/
    18. }
    19. else
    20. {
    21. // Rotation Code will go here later
    22. }
    23. }
    24. else
    25. {
    26. mNode->translate(mDirection * move);
    27. }
    28.  
    29. }
    30.  
    31. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by rimie23; 11th June 2012 at 01:27.

Similar Threads

  1. Problem with automatically resizing label text
    By glennr in forum Qt Programming
    Replies: 0
    Last Post: 4th January 2012, 23:11
  2. Arkanoid and animation problem
    By kornicameister in forum Qt Quick
    Replies: 0
    Last Post: 26th August 2011, 16:03
  3. Problem With Animation
    By A.H.M. Mahfuzur Rahman in forum Qt Programming
    Replies: 2
    Last Post: 21st July 2009, 07:23
  4. Replies: 0
    Last Post: 2nd March 2009, 13:49
  5. Replies: 12
    Last Post: 3rd April 2006, 07:11

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
  •  
Qt is a trademark of The Qt Company.