提交 146d1fee 编写于 作者: mahuifa's avatar mahuifa

feat:设置程序 图标

上级 1195d65c
......@@ -34,7 +34,6 @@ SOURCES += \
screenrect.cpp \
windowrect.cpp
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
......@@ -43,6 +42,7 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
# 定义程序版本号
VERSION = 1.0.0
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
RC_ICONS = icon.ico # 设置程序图标
contains(QT_ARCH, i386){ # 使用32位编译器
DESTDIR = $$PWD/../bin # 程序输出路径
......@@ -61,3 +61,5 @@ LIBS+= -luser32 # 使用WindowsAPI需要链接库
unix:!macx{
LIBS += -lX11 # linux获取窗口信息需要用到xlib
}
RESOURCES += rc.qrc
......@@ -20,22 +20,21 @@ MainWindow::MainWindow(QWidget *parent)
this->setWindowTitle(QString("Qt-截图工具 - V%1").arg(APP_VERSION));
// 设置工具栏
QAction* acNew = new QAction("新建截图");
QAction* acSave = new QAction("保存截图");
QAction* acClear = new QAction("取消截图");
QAction* acNew = new QAction(QIcon(":/img/剪切.ico"), "新建截图");
QAction* acSave = new QAction(QIcon(":/img/保存.ico"), "保存截图");
QAction* acClear = new QAction(QIcon(":/img/取消.ico"), "取消截图");
m_acModel = new QAction(QIcon(":/img/选区.ico"), "截图模式");
QMenu* menu = new QMenu(this);
menu->addAction(new QAction("全屏", this));
menu->addAction(new QAction("矩形", this));
menu->addAction(new QAction("窗口", this));
m_butModel = new QToolButton();
m_butModel->setPopupMode(QToolButton::InstantPopup);
m_butModel->setMenu(menu);
m_butModel->setText("模式");
QToolBar* toolbar = new QToolBar(this);
m_acModel->setMenu(menu);
toolbar->addAction(acNew);
toolbar->addWidget(m_butModel);
toolbar->addAction(m_acModel);
toolbar->addAction(acSave);
toolbar->addAction(acClear);
toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
this->addToolBar(Qt::TopToolBarArea, toolbar); // 添加工具栏
connect(menu, &QMenu::triggered, this, &MainWindow::on_triggered);
connect(acNew, &QAction::triggered, this, &MainWindow::on_newGrab);
......@@ -57,13 +56,13 @@ MainWindow::~MainWindow()
*/
void MainWindow::on_triggered(QAction *action)
{
m_butModel->setText(action->text());
m_acModel->setText(action->text());
}
void MainWindow::on_newGrab(bool checked)
{
Q_UNUSED(checked)
QString strModel = m_butModel->text();
QString strModel = m_acModel->text();
if(strModel == "全屏")
{
grabPixmap(QRect(0, 0, -1, -1));
......
......@@ -28,7 +28,7 @@ protected:
private:
Ui::MainWindow *ui;
QToolButton* m_butModel = nullptr;
QAction* m_acModel = nullptr;
QPixmap m_pixmap; // 保存截取的图像
ScreenRect m_screenRect;
WindowRect m_windowRect;
......
......@@ -16,7 +16,7 @@
<property name="styleSheet">
<string notr="true">/********************QToolBar样式**********************/
QToolButton {
width: 80px;
width: 100px;
height: 30px;
}
</string>
......
<RCC>
<qresource prefix="/">
<file>img/保存.ico</file>
<file>img/剪切.ico</file>
<file>img/取消.ico</file>
<file>img/选区.ico</file>
</qresource>
</RCC>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册