Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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*)));

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
*/
}
4 changes: 4 additions & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -48,6 +50,8 @@ private slots:



void on_actionback_triggered();

private:
Ui::MainWindow *ui;

Expand Down
10 changes: 8 additions & 2 deletions mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@
</widget>
<widget class="QStackedWidget" name="stackedWidgetExtraInfo">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="page_3">
<layout class="QVBoxLayout" name="verticalLayout_2"/>
Expand Down Expand Up @@ -758,13 +758,14 @@
<x>0</x>
<y>0</y>
<width>941</width>
<height>23</height>
<height>26</height>
</rect>
</property>
<widget class="QMenu" name="menu_System">
<property name="title">
<string>&amp;System</string>
</property>
<addaction name="actionback"/>
<addaction name="actionQuit"/>
</widget>
<widget class="QMenu" name="menu_About">
Expand All @@ -787,6 +788,11 @@
<string>&amp;About</string>
</property>
</action>
<action name="actionback">
<property name="text">
<string>back</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
Expand Down
2 changes: 1 addition & 1 deletion stock.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define STOCK_H

#include <QObject>

#include <QMutex>
#include "common.h"


Expand Down