SampleEditor
Line 40: | Line 40: | ||
signals: | signals: | ||
private: | private: | ||
− | + | void createMenus(); | |
− | + | void createStatusBar(); | |
− | + | QMenu *fileMenu; | |
QAction *loadAction; | QAction *loadAction; | ||
QStandardItemModel *model; | QStandardItemModel *model; |
Revision as of 21:28, 10 July 2009
The SampleEditor program (checkout from the FARSIGHT repository) is implemented by using the QT's model/view architecture. This web page is prepared to help one to implement their code by using this model. (Please visit hese pages for additional information:
* ALISA shows how we implement QT's Model/View Architecture in FARSIGHT, specifically in the NucleusEditor module.
* EVS presents Edit-based Validation and Model-View Programming)
Why do we need to use this architecture?
In general, there are many applications that follow some of the steps listed below:
- 1. Read Some Input - Read the data from a file, from the command line, or from the program itself
- 2. Present the Data Using Different Views - Show it with a table, draw a scatter plott, or display some columns buy using a histogram
- 3. Edit the Data in the Views - reflect the changes to all the other views, update them properly
- 4. Compute some features
- 5. Write/Store the Results - into a file, or to the screen
In Farsight, our modules follow the similar patterns to process the data. In order to implement these steps, many different solutions might be provided. The major problem with this approach is that for every unique solution, the programmer needs to implement their specialized viewers. An alternative and a better solution is to base your application onto the model/view architecture that we have already implemented. The advantage is that your module will be able to view the data with a small amount of extra programming by using the different viewers that are implemented in our libraries.
We show, in the SampleEditor program, how this idea works. For simplicity, we view the data by using only three views. Here are the screen shots of these views from the SampleEditor program:
- 1. Table View
- 2. Scatter Plot View
- 3. Histogram View
In this architecture, any changes in one of the views will be reflected to the other viewers immidiately.
Steps
Here is the main class that we defined for the SampleEditor:
class SampleEditor : public QMainWindow { Q_OBJECT; public:
SampleEditor(QWidget * parent = 0, Qt::WindowFlags flags = 0);
private slots:
void loadFile(void);
signals: private: void createMenus(); void createStatusBar(); QMenu *fileMenu;
QAction *loadAction; QStandardItemModel *model; QItemSelectionModel *selModel; QTableView *table; PlotWindow *plot; HistoWindow *histo;
};