diff --git a/mainwindow.cpp b/mainwindow.cpp index 2a5da37..4411803 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -9,6 +9,8 @@ MainWindow::MainWindow(QWidget *parent) : ui->setupUi(this); ui->stackedWidgetExtraInfo->hide(); + connect(ui->menu_System, SIGNAL(click()), this, SLOT(switchPage()), Qt::QueuedConnection); + connect(ui->tableViewStocks, SIGNAL(stockActivated(Stock*)), this, SLOT(stockActivated(Stock*))); connect(ui->tableViewStocks, SIGNAL(stockSelected(Stock*)), this, SLOT(stockSelected(Stock*))); @@ -64,7 +66,15 @@ MainWindow::~MainWindow() void MainWindow::closeEvent(QCloseEvent *event){ event->accept(); } - +void MainWindow::keyPressEvent(QKeyEvent* e) +{ + switch (e->key()) + { + case Qt::Key_Enter: + switchPage(); + break; + } +} void MainWindow::updateRealTimeQuoteData(const RealTimeQuoteData &data){ Stock *stock = m_dataManager->stock(data.code); @@ -209,3 +219,21 @@ void MainWindow::on_actionAbout_triggered(){ + +void MainWindow::on_actionback_triggered() +{ + switchPage(); + /* + int nCount = ui->stackedWidget->count(); + int nIndex = ui->stackedWidget->currentIndex(); + + // 获取下一个需要显示的页面索引 + ++nIndex; + + // 当需要显示的页面索引大于等于总页面时,切换至首页 + if (nIndex >= nCount) + nIndex = 0; + + ui->stackedWidget->setCurrentIndex(nIndex); + */ +} diff --git a/mainwindow.h b/mainwindow.h index 04ad837..c5c10c4 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -28,6 +28,8 @@ class MainWindow : public QMainWindow protected: void closeEvent(QCloseEvent *event); +private slots: + void keyPressEvent(QKeyEvent* event); public slots: void updateRealTimeQuoteData(const RealTimeQuoteData &data); @@ -48,6 +50,8 @@ private slots: + void on_actionback_triggered(); + private: Ui::MainWindow *ui; diff --git a/mainwindow.ui b/mainwindow.ui index fd9a82c..0f803fd 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -325,7 +325,7 @@ - 0 + 1 @@ -758,13 +758,14 @@ 0 0 941 - 23 + 26 &System + @@ -787,6 +788,11 @@ &About + + + back + + diff --git a/stock.h b/stock.h index 80348ee..37c2d9b 100644 --- a/stock.h +++ b/stock.h @@ -2,7 +2,7 @@ #define STOCK_H #include - +#include #include "common.h"