資源簡介
適用于windows和linux下的抓圖
基本功能已完成,還有一些小細節問題以后慢慢解決
代碼片段和文件信息
#include?“grabwindows.h“
#include?“screenshotpart.h“
GrabWindows::GrabWindows(QWidget?*parent)
????:?QDialog(parent?Qt::WindowMinimizeButtonHint?|?Qt::WindowCloseButtonHint)
{
????setWindowIcon(QIcon(“:/applets-screenshooter.png“));
????setWindowtitle(tr(“screenshot“));
????iconPix?=?QPixmap(“:/applets-screenshooter.png“);
????buttonGroup?=?new?QButtonGroup(this);
????QRadioButton?*grabDeskTop?=?new?QRadioButton(this);
???//?grabDeskTop->setShortcut(QKeySequence(tr(“Alt+D“)));
????grabDeskTop->setText(tr(“Grab?Qll?&Desktop“));
????grabDeskTop->move(70?30);
????grabDeskTop->setChecked(true);
????buttonGroup->addButton(grabDeskTop?0);
????QRadioButton?*grabCurrentWindow?=?new?QRadioButton(this);
????grabCurrentWindow->setText(tr(“Grab?Current?&Window“));
????grabCurrentWindow->move(70?55);
????buttonGroup->addButton(grabCurrentWindow?1);
????QRadioButton?*grabPartArea?=?new?QRadioButton(this);
????grabPartArea->setText(tr(“Choose?Part?&Area“));
????grabPartArea->move(70?85);
????buttonGroup->addButton(grabPartArea?2);
????timeDelayLabel?=?new?QLabel(tr(“DelyBefore&Grab“)?this);
????timeDelayLabel->setGeometry(70?120?100?20);
????timeComBox?=?new?QSpinBox(this);
????timeComBox->setGeometry(175?118?55?25);
????timeComBox->setRange(0?99);
????timeDelayLabel->setBuddy(timeComBox);
????QLabel?*secondLabel?=?new?QLabel(tr(“s“)?this);
????secondLabel->setGeometry(235?120?20?20);
????QPushButton?*cacelBtn?=?new?QPushButton(this);
????cacelBtn->resize(85?30);
????cacelBtn->move(60?160);
????cacelBtn->setText(tr(“&Cancel“));
????connect(cacelBtn?SIGNAL(clicked())?this?SLOT(hide()));
????QPushButton?*grabBtn?=?new?QPushButton(this);
????grabBtn->resize(85?30);
????grabBtn->move(160?160);
????grabBtn->setText(tr(“&Screenshot“));
????connect(grabBtn?SIGNAL(clicked())?this?SLOT(slotGrabWindows()));
????connect(buttonGroup?SIGNAL(buttonclicked(int))?this?SLOT(slotButtonGroup(int)));
????
????initTrayiconMenu();
????resize(290?210);
????move((QApplication::desktop()->width()?-?width())/2??(QApplication::desktop()->height()?-?height())/2);
}
GrabWindows::~GrabWindows()
{
}
void?GrabWindows::paintEvent(QPaintEvent?*event)
{
????QPainter?painter(this);
????painter.setPen(QPen(QColor(“#000000“)?2?Qt::SolidLine?Qt::RoundCap?Qt::RoundJoin));
????painter.setFont(QFont(“arial“?10?QFont::Black));
????painter.drawText(QRect(10?10?60?60)?QString(tr(“Grabwindow“)));
????painter.drawPixmap(QRect(10?30?iconPix.width()?iconPix.height())?iconPix);
}
void?GrabWindows::slotSaveFullScreen()
{
????timer->stop();
????fullScreenPixmap?=?QPixmap::grabWindow(QApplication::desktop()->winId());
????savePix?=?new?ScreenShotSave(fullScreenPixmap);
????savePix->exec();
????delete?savePix;
????savePix?=?NULL;
????show();
}
void?GrabWindows::slotSaveCurrentScreen()
{
????show();
????if?(QApplication::activeWindow())?{
????????timer->stop();
????????currentScreenPixmap?=?QPixmap::grabWindow(?QApplication::activeWindow()->winId()?
- 上一篇:連分數與歷法 初等數論
- 下一篇:SDH基本原理講解,相信看了你對SDH立刻明白
評論
共有 條評論