Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

CModDocument.cpp

By: egor7 on Jul 12th, 2011  |  syntax: C++ (with QT extensions)  |  size: 1.73 KB  |  hits: 141  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <QtGui>
  2. #include <QDebug>
  3.  
  4. #include <QtGui>
  5. #include "CModDocument.h"
  6.  
  7. CModDocument::CModDocument( QWidget *parent )
  8. : QWidget( parent )
  9. , mainWnd( (QMainWindow*)parent )
  10. {
  11.  
  12.         createActions();
  13.         createToolBars();
  14.         interCom();
  15.  
  16.         mainWnd->statusBar()->showMessage(tr("Ready"));
  17.  
  18. }
  19.  
  20. void CModDocument::newFile()
  21. {
  22.         qDebug() << "newFile";
  23. }
  24.  
  25. void CModDocument::open()
  26. {
  27.         qDebug() << "open";
  28. }
  29.  
  30. bool CModDocument::save()
  31. {
  32.         qDebug() << "save";
  33.         bool retVal;
  34.         return retVal;
  35. }
  36.  
  37. bool CModDocument::saveAs()
  38. {
  39.         qDebug() << "saveAs";
  40.         bool retVal;
  41.         return retVal;
  42. }
  43.  
  44.  
  45. void CModDocument::createActions()
  46. {
  47.  
  48.         newAct = new QAction(tr("&New"), this);
  49.         newAct->setShortcuts(QKeySequence::New);
  50.         newAct->setStatusTip(tr("Create a new file"));
  51.  
  52.         openAct = new QAction(tr("&Open..."), this);
  53.         openAct->setShortcuts(QKeySequence::Open);
  54.         openAct->setStatusTip(tr("Open an existing file"));
  55.  
  56.         saveAct = new QAction(tr("&Save"), this);
  57.         saveAct->setShortcuts(QKeySequence::Save);
  58.         saveAct->setStatusTip(tr("Save the document to disk"));
  59.  
  60.         saveAsAct = new QAction(tr("Save &As..."), this);
  61.         saveAsAct->setShortcuts(QKeySequence::SaveAs);
  62.         saveAsAct->setStatusTip(tr("Save the document under a new name"));
  63.  
  64. }
  65.  
  66. void CModDocument::createToolBars()
  67. {
  68.  
  69.     fileToolBar = mainWnd->addToolBar(tr("File"));
  70.     fileToolBar->addAction(newAct);
  71.     fileToolBar->addAction(openAct);
  72.     fileToolBar->addAction(saveAct);
  73.  
  74. }
  75.  
  76. void CModDocument::interCom()
  77. {
  78.  
  79.         connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));
  80.         connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
  81.         connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));
  82.         connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));
  83.  
  84.  
  85.  
  86. }