📄 window.cpp
字号:
#include "window.h"
#include<QtGui>
window::window(QWidget *parent):QWidget(parent)
{
next= new QPushButton(tr("NEXT"));
prev= new QPushButton(tr("PREV"));
this->setFocus(Qt::ActiveWindowFocusReason);
QHBoxLayout *hlayout = new QHBoxLayout;
hlayout->addWidget(next);
hlayout->addWidget(prev);
QVBoxLayout *vlayout = new QVBoxLayout;
pic = new picture;
vlayout->addWidget(pic);
vlayout->addLayout(hlayout);
setLayout(vlayout);
setWindowTitle(tr("PICTURE"));
//setFixedHeight(sizeHint().height());
//std::cout<<"the key baoad"<<press.key ();
connect(next,SIGNAL(clicked()),this,SLOT(nextpicture()));
connect(prev,SIGNAL(clicked()),this,SLOT(prevpicture()));
//connect(,SIGNAL(key()), this,SLOT(prevpicture()));
}
void window::keyPressEvent(QKeyEvent *event)
{
switch(event->key())
{ case Qt::Key_Right: nextpicture(); break;
case Qt::Key_Left: prevpicture(); break;
case Qt::Key_Up: prevpicture(); break;
case Qt::Key_Down: nextpicture(); break;
case 65: zoomout(); break;
case 68: zoomin(); break;
}
qDebug()<<"key press"<<event->key();
}
void window::zoomin()
{
pic->changerect(true,true);
}
void window::zoomout()
{
pic->changerect(false,true);
}
void window::nextpicture()
{
pic->next();
}
void window::prevpicture()
{
pic->prev();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -