class Foo{ public: Foo(); protected: m_member;}class Boo : public Foo{ public: Boo();}
C++ (Qt)#ifndef MAINWINDOW_H#define MAINWINDOW_H #include <QMainWindow> namespace Ui { class MainWindow;} class MainWindow : public QMainWindow{ Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private: Ui::MainWindow *ui;public slots: void mySlot();}; #endif // MAINWINDOW_H
C++ (Qt)#include "mainwindow.h"#include "ui_mainwindow.h"#include "QTime"#include "QTimer" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ ui->setupUi(this); QTimer mytimer; QObject::connect(&mytimer, SIGNAL( timeout() ), this, SLOT(mySlot()));} void MainWindow::mySlot(){QTime time_obj;ui->timeEdit->setTime(time_obj.currentTime());} MainWindow::~MainWindow(){ delete ui;}
C++ (Qt)#ifndef MAINWINDOW_H#define MAINWINDOW_H #include <QMainWindow>#include "QTime"#include "QTimer"namespace Ui { class MainWindow;} class MainWindow : public QMainWindow{ Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); QTimer mytimer; QDate curDate;private: Ui::MainWindow *ui;public slots: void mySlot();}; #endif // MAINWINDOW_H
C++ (Qt)#include "mainwindow.h"#include "ui_mainwindow.h"#include "QTime"#include "QTimer"#include "QDate" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ ui->setupUi(this); mytimer.start(); QObject::connect(&mytimer, SIGNAL( timeout() ), this, SLOT(mySlot())); curDate = QDate::currentDate();} void MainWindow::mySlot(){ QTime time_obj; ui->timeEdit->setTime(time_obj.currentTime()); ui->lcdNumber_2->display(curDate.toString("d"));} MainWindow::~MainWindow(){ delete ui;}