tags:

views:

121

answers:

2

Currently Im using QT Creator which created UI file for view and I'm a QT starter.

There is a part I am curious is that how can i create another Class for, let say a GraphicView, so that I can send signal and slot to that class instead of the main form?

Side Question: why I can't edit Singal and Slot in other place than MainWindow in Edit Signal/Slot Mode? (the edit button is not activated if it's not MainWindow, so i have to use those default Signal) Let say i need to create a ToggleFullScreen() but the edit is gray out, how do I do it?

A: 
  1. Signals and Slots
  2. You have to create a derived class that inherits from QMainWindow if you want to add new signals or slots.
Adam W
can you tell more example on the number 2?
DucDigital
also the question is that how can i attach one, let say, GraphicView, to the Class? just let them have the same name?
DucDigital
@DucDigital: Here is an example of 2: http://doc.trolltech.com/4.6/mainwindows-application.html When you say the same name, do you mean class name or instance name? If you mean class name, you just create a new instance, if you mean instance, you need to brush up on your C++. Are you just starting to lean C++ while you lean Qt, or do you have a solid background already?
Adam W
A: 

Hi,

Adam is right.
But there are several ways to use a UI file in your application.
Have a look at http://qt.nokia.com/doc/4.5/designer-using-a-ui-file.html

For signal-slot specific question : see the link in Adam answer.
But, in summary, if you declare the Q_OBJECT macro in yours classes, you can communicate between those by signal-slot mechanism !

Matthieu