LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-05-2004, 03:38 PM   #1
jki25
LQ Newbie
 
Registered: Jan 2004
Posts: 3

Rep: Reputation: 0
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
 
Old 01-05-2004, 05:54 PM   #2
leonscape
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Debian SID / KDE 3.5
Posts: 2,313

Rep: Reputation: 47
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.
 
Old 01-05-2004, 08:55 PM   #3
jki25
LQ Newbie
 
Registered: Jan 2004
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks! That does help with the new, open, save and save as.
Any thoughts on the redo or undo?
Thanks again,
jki25
 
Old 01-05-2004, 09:40 PM   #4
leonscape
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Debian SID / KDE 3.5
Posts: 2,313

Rep: Reputation: 47
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.
 
Old 01-07-2004, 11:58 AM   #5
jki25
LQ Newbie
 
Registered: Jan 2004
Posts: 3

Original Poster
Rep: Reputation: 0
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting php5 socket functions to php3 socket functions mrobertson Programming 0 06-23-2005 10:11 AM
Qt Designer HELP! dolvmin Linux - Software 1 07-20-2004 11:11 PM
Qt designer Rozi Linux - Software 0 05-19-2004 10:49 AM
QT Designer Tynoan Linux - Software 0 09-10-2003 03:40 PM
pointers to functions/member functions champ Programming 2 03-28-2003 07:22 PM


All times are GMT -5. The time now is 10:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration