LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Help with QT designer menu functions (https://www.linuxquestions.org/questions/linux-software-2/help-with-qt-designer-menu-functions-131783/)

jki25 01-05-2004 02:38 PM

Help with QT designer menu functions
 
Using Qt designer 3.0.
Need code examples for menu functions: new, open, save, save as, redo and undo.
Can open a file dialog box but then need to get file name from user and check if file already exists. Just need something simple to go by.
Completely clueless on the undo, redo.
THanks,
jki25

leonscape 01-05-2004 04:54 PM

Have you looked at the examples and tutorials for Qt?

The Trolltech Developer homepage has lots of useful info. Look at the stuff under qt examples specifically the things about Actions.

jki25 01-05-2004 07:55 PM

Thanks! That does help with the new, open, save and save as.
Any thoughts on the redo or undo?
Thanks again,
jki25

leonscape 01-05-2004 08:40 PM

What exactly are you after? Doing undos and redos is very specific to the task at hand.

I create a base class that stores info on where a value came from ( a QWidget* ). Then in some derived classes add specifics about the values ( creating a derived that say takes doubles, one that takes QString, one that takes ... well you get the idea ). Then in the widgets If the value changes they create a derived class and emit a base class pointer the derived class as a signal.

In the main class I attach the widgets signal to a slot. This slot takes the base class pointer and adds it to a QPtrList. If the list count reaches what ever maximum is decided I pop off the front of the list.

Now when undo is pressed I pop off the last pointer added then call a function in the widget specified by the pointer in the base class. Of course the function in the widget then does a dynamic cast and reclaims the old value. Once this has returned, I then add the base class pointer to a second QPtrList, which is for redo. Which of course behave almost exactly the same as undo.

This is a basic undo/redo mechanism. The derived class could say take another class as a value, or multiple values. As long as the widget knows what to do with the pointer.

If this is not what you meant, or I didn't explain myself properly :) let me know.

jki25 01-07-2004 10:58 AM

This helps more than you can ever know. Basically, i have an assignment for a programming class that involves filling in all of the menu functions for a gui that the professor wrote, but the class (and professor) are new to Qt. So, i am trying to decipher what he has already coded and write all of the redo, undo, save as, etc.
Didnt really explain this whole widget thing to us and its taken some time to understand whats really going on. Your advice helps immensely.
Thanks,
jki25


All times are GMT -5. The time now is 02:14 AM.