Advertisement
Guest User

Untitled

a guest
Apr 4th, 2016
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.03 KB | None | 0 0
  1. //MainWindow.h
  2. #ifndef MAINWINDOW_H
  3. #define MAINWINDOW_H
  4.  
  5. #include <QMainWindow>
  6. #include <DbManager.h>
  7.  
  8. namespace Ui {
  9. class MainWindow;
  10. }
  11.  
  12. class MainWindow : public QMainWindow
  13. {
  14.     Q_OBJECT
  15.  
  16. public:
  17.     explicit MainWindow(QWidget *parent = 0);
  18.     ~MainWindow();
  19.  
  20. private:
  21.     Ui::MainWindow *ui;
  22.  
  23.     DbManager db_test;
  24. };
  25.  
  26. #endif // MAINWINDOW_H
  27.  
  28. // MainWindow.cpp
  29. #include "Mainwindow.h"
  30. #include "ui_Mainwindow.h"
  31.  
  32. MainWindow::MainWindow(QWidget *parent) :
  33.     QMainWindow(parent),
  34.     ui(new Ui::MainWindow)
  35. {
  36.     ui->setupUi(this);
  37. }
  38.  
  39. MainWindow::~MainWindow()
  40. {
  41.     delete ui;
  42. }
  43.  
  44.  
  45. // Bar.h
  46. #ifndef BAR_H
  47. #define BAR_H
  48.  
  49. #include <QWidget>
  50.  
  51. namespace Ui {
  52. class Bar;
  53. }
  54.  
  55. class Bar : public QWidget
  56. {
  57.     Q_OBJECT
  58.  
  59. public:
  60.     explicit Bar(QWidget *parent = 0);
  61.     ~Bar();
  62.  
  63. private:
  64.     Ui::Bar *ui;
  65.  
  66. };
  67.  
  68. #endif // BAR_H
  69.  
  70. // Bar.cpp
  71. #include "Bar.h"
  72. #include "ui_Bar.h"
  73.  
  74. Bar::Bar(QWidget *parent) :
  75.     QWidget(parent),
  76.     ui(new Ui::Bar)
  77. {
  78.     ui->setupUi(this);
  79. }
  80.  
  81. Bar::~Bar()
  82. {
  83.     delete ui;
  84. }
  85.  
  86.  
  87. //Foo.h
  88. #ifndef FOO_H
  89. #define FOO_H
  90.  
  91. #include <QWidget>
  92.  
  93. namespace Ui {
  94. class Foo;
  95. }
  96.  
  97. class Foo : public QWidget
  98. {
  99.     Q_OBJECT
  100.  
  101. public:
  102.     explicit Foo(QWidget *parent = 0);
  103.     ~Foo();
  104.  
  105. private:
  106.     Ui::Foo *ui;
  107. };
  108.  
  109. #endif // FOO_H
  110.  
  111. //Foo.cpp
  112. #include "Foo.h"
  113. #include "ui_Foo.h"
  114.  
  115. Foo::Foo(QWidget *parent) :
  116.     QWidget(parent),
  117.     ui(new Ui::Foo)
  118. {
  119.     ui->setupUi(this);
  120. }
  121.  
  122. Foo::~Foo()
  123. {
  124.     delete ui;
  125. }
  126.  
  127. //DbManager.h
  128. #ifndef DBMANAGER_H
  129. #define DBMANAGER_H
  130.  
  131. #include <QDebug>
  132.  
  133. class DbManager
  134. {
  135. public:
  136.     DbManager();
  137.  
  138.     void do_something();
  139. };
  140.  
  141. #endif // DBMANAGER_H
  142.  
  143. //DbManager.cpp
  144. #include "DbManager.h"
  145.  
  146. DbManager::DbManager()
  147. {
  148.  
  149. }
  150.  
  151. void DbManager::do_something()
  152. {
  153.     qDebug() << "do something";
  154. }
  155.  
  156. //main.cpp
  157. #include "Mainwindow.h"
  158. #include <QApplication>
  159.  
  160. int main(int argc, char *argv[])
  161. {
  162.     QApplication a(argc, argv);
  163.     MainWindow w;
  164.     w.show();
  165.  
  166.     return a.exec();
  167. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement