修正大量demo
This commit is contained in:
@@ -86,14 +86,14 @@ ColorWidget::ColorWidget(QWidget *parent) : QWidget(parent)
|
||||
txtPoint = new QLineEdit(this);
|
||||
gridLayout->addWidget(txtPoint, 2, 2, 1, 1);
|
||||
|
||||
label->setText("当前颜色显示");
|
||||
label->setText("当前颜色");
|
||||
labWeb->setText("web值:");
|
||||
labRgb->setText("rgb值:");
|
||||
labPoint->setText("坐标值:");
|
||||
|
||||
this->setLayout(gridLayout);
|
||||
this->setWindowTitle("屏幕拾色器");
|
||||
this->setFixedSize(270, 108);
|
||||
this->setFixedSize(300, 108);
|
||||
|
||||
cp = QApplication::clipboard();
|
||||
pressed = false;
|
||||
|
||||
@@ -14,5 +14,10 @@ DESTDIR = $$PWD/../bin
|
||||
CONFIG += warn_off
|
||||
|
||||
SOURCES += main.cpp
|
||||
SOURCES += frmcolorwidget.cpp
|
||||
SOURCES += colorwidget.cpp
|
||||
|
||||
HEADERS += colorwidget.h
|
||||
HEADERS += frmcolorwidget.h
|
||||
|
||||
FORMS += frmcolorwidget.ui
|
||||
|
||||
18
colorwidget/frmcolorwidget.cpp
Normal file
18
colorwidget/frmcolorwidget.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "frmcolorwidget.h"
|
||||
#include "ui_frmcolorwidget.h"
|
||||
#include "colorwidget.h"
|
||||
|
||||
frmColorWidget::frmColorWidget(QWidget *parent) : QWidget(parent), ui(new Ui::frmColorWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
frmColorWidget::~frmColorWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void frmColorWidget::on_pushButton_clicked()
|
||||
{
|
||||
ColorWidget::Instance()->show();
|
||||
}
|
||||
25
colorwidget/frmcolorwidget.h
Normal file
25
colorwidget/frmcolorwidget.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef FRMCOLORWIDGET_H
|
||||
#define FRMCOLORWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class frmColorWidget;
|
||||
}
|
||||
|
||||
class frmColorWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit frmColorWidget(QWidget *parent = 0);
|
||||
~frmColorWidget();
|
||||
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
|
||||
private:
|
||||
Ui::frmColorWidget *ui;
|
||||
};
|
||||
|
||||
#endif // FRMCOLORWIDGET_H
|
||||
32
colorwidget/frmcolorwidget.ui
Normal file
32
colorwidget/frmcolorwidget.ui
Normal file
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>frmColorWidget</class>
|
||||
<widget class="QWidget" name="frmColorWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>92</width>
|
||||
<height>28</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>弹出</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -1,9 +1,8 @@
|
||||
#pragma execution_character_set("utf-8")
|
||||
|
||||
#include "colorwidget.h"
|
||||
#include "frmcolorwidget.h"
|
||||
#include <QApplication>
|
||||
#include <QTextCodec>
|
||||
#include <QIcon>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -24,7 +23,9 @@ int main(int argc, char *argv[])
|
||||
QTextCodec::setCodecForLocale(codec);
|
||||
#endif
|
||||
|
||||
ColorWidget::Instance()->show();
|
||||
frmColorWidget w;
|
||||
w.setWindowTitle("屏幕拾色器");
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ void frmFramelessWidget::closeEvent(QCloseEvent *)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void frmFramelessWidget::on_btnOpen_clicked()
|
||||
void frmFramelessWidget::on_pushButton_clicked()
|
||||
{
|
||||
if (w == 0) {
|
||||
w = new QWidget;
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
#include <QWidget>
|
||||
class FramelessWidget;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
namespace Ui {
|
||||
class frmFramelessWidget;
|
||||
}
|
||||
|
||||
@@ -26,7 +25,7 @@ private:
|
||||
FramelessWidget *frameless;
|
||||
|
||||
private slots:
|
||||
void on_btnOpen_clicked();
|
||||
void on_pushButton_clicked();
|
||||
void stateChanged1(int arg1);
|
||||
void stateChanged2(int arg1);
|
||||
};
|
||||
|
||||
@@ -13,17 +13,17 @@
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QPushButton" name="btnOpen">
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>181</width>
|
||||
<height>23</height>
|
||||
<width>92</width>
|
||||
<height>28</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>弹窗无边框窗体</string>
|
||||
<string>弹出</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
18
gifwidget/frmgifwidget.cpp
Normal file
18
gifwidget/frmgifwidget.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "frmgifwidget.h"
|
||||
#include "ui_frmgifwidget.h"
|
||||
#include "gifwidget.h"
|
||||
|
||||
frmGifWidget::frmGifWidget(QWidget *parent) : QWidget(parent), ui(new Ui::frmGifWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
frmGifWidget::~frmGifWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void frmGifWidget::on_pushButton_clicked()
|
||||
{
|
||||
GifWidget::Instance()->show();
|
||||
}
|
||||
25
gifwidget/frmgifwidget.h
Normal file
25
gifwidget/frmgifwidget.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef FRMGIFWIDGET_H
|
||||
#define FRMGIFWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class frmGifWidget;
|
||||
}
|
||||
|
||||
class frmGifWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit frmGifWidget(QWidget *parent = 0);
|
||||
~frmGifWidget();
|
||||
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
|
||||
private:
|
||||
Ui::frmGifWidget *ui;
|
||||
};
|
||||
|
||||
#endif // FRMGIFWIDGET_H
|
||||
32
gifwidget/frmgifwidget.ui
Normal file
32
gifwidget/frmgifwidget.ui
Normal file
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>frmGifWidget</class>
|
||||
<widget class="QWidget" name="frmGifWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>92</width>
|
||||
<height>28</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>弹出</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -72,16 +72,13 @@ public:
|
||||
};
|
||||
|
||||
// max, min, and abs functions
|
||||
int GifIMax(int l, int r)
|
||||
{
|
||||
int GifIMax(int l, int r) {
|
||||
return l > r ? l : r;
|
||||
}
|
||||
int GifIMin(int l, int r)
|
||||
{
|
||||
int GifIMin(int l, int r) {
|
||||
return l < r ? l : r;
|
||||
}
|
||||
int GifIAbs(int i)
|
||||
{
|
||||
int GifIAbs(int i) {
|
||||
return i < 0 ? -i : i;
|
||||
}
|
||||
|
||||
@@ -89,8 +86,7 @@ public:
|
||||
// Takes as in/out parameters the current best color and its error -
|
||||
// only changes them if it finds a better color in its subtree.
|
||||
// this is the major hotspot in the code at the moment.
|
||||
void GifGetClosestPaletteColor(GifPalette *pPal, int r, int g, int b, int &bestInd, int &bestDiff, int treeRoot = 1)
|
||||
{
|
||||
void GifGetClosestPaletteColor(GifPalette *pPal, int r, int g, int b, int &bestInd, int &bestDiff, int treeRoot = 1) {
|
||||
// base case, reached the bottom of the tree
|
||||
if (treeRoot > (1 << pPal->bitDepth) - 1) {
|
||||
int ind = treeRoot - (1 << pPal->bitDepth);
|
||||
@@ -131,8 +127,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void GifSwapPixels(uint8_t *image, int pixA, int pixB)
|
||||
{
|
||||
void GifSwapPixels(uint8_t *image, int pixA, int pixB) {
|
||||
uint8_t rA = image[pixA * 4];
|
||||
uint8_t gA = image[pixA * 4 + 1];
|
||||
uint8_t bA = image[pixA * 4 + 2];
|
||||
@@ -155,8 +150,7 @@ public:
|
||||
}
|
||||
|
||||
// just the partition operation from quicksort
|
||||
int GifPartition(uint8_t *image, const int left, const int right, const int elt, int pivotIndex)
|
||||
{
|
||||
int GifPartition(uint8_t *image, const int left, const int right, const int elt, int pivotIndex) {
|
||||
const int pivotValue = image[(pivotIndex) * 4 + elt];
|
||||
GifSwapPixels(image, pivotIndex, right - 1);
|
||||
int storeIndex = left;
|
||||
@@ -179,8 +173,7 @@ public:
|
||||
}
|
||||
|
||||
// Perform an incomplete sort, finding all elements above and below the desired median
|
||||
void GifPartitionByMedian(uint8_t *image, int left, int right, int com, int neededCenter)
|
||||
{
|
||||
void GifPartitionByMedian(uint8_t *image, int left, int right, int com, int neededCenter) {
|
||||
if (left < right - 1) {
|
||||
int pivotIndex = left + (right - left) / 2;
|
||||
pivotIndex = GifPartition(image, left, right, com, pivotIndex);
|
||||
@@ -199,8 +192,7 @@ public:
|
||||
int numPixels, int firstElt,
|
||||
int lastElt, int splitElt,
|
||||
int splitDist, int treeNode,
|
||||
bool buildForDither, GifPalette *pal)
|
||||
{
|
||||
bool buildForDither, GifPalette *pal) {
|
||||
if (lastElt <= firstElt || numPixels == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -318,8 +310,7 @@ public:
|
||||
// moves them to the fromt of th buffer.
|
||||
// This allows us to build a palette optimized for the colors of the
|
||||
// changed pixels only.
|
||||
int GifPickChangedPixels( const uint8_t *lastFrame, uint8_t *frame, int numPixels )
|
||||
{
|
||||
int GifPickChangedPixels(const uint8_t *lastFrame, uint8_t *frame, int numPixels) {
|
||||
int numChanged = 0;
|
||||
uint8_t *writeIter = frame;
|
||||
for (int ii = 0; ii < numPixels; ++ii) {
|
||||
@@ -344,8 +335,7 @@ public:
|
||||
const uint8_t *nextFrame,
|
||||
uint32_t width, uint32_t height,
|
||||
int bitDepth, bool buildForDither,
|
||||
GifPalette *pPal )
|
||||
{
|
||||
GifPalette *pPal) {
|
||||
pPal->bitDepth = bitDepth;
|
||||
|
||||
// SplitPalette is destructive (it sorts the pixels by color) so
|
||||
@@ -377,8 +367,7 @@ public:
|
||||
// Implements Floyd-Steinberg dithering, writes palette value to alpha
|
||||
void GifDitherImage(const uint8_t *lastFrame, const uint8_t *nextFrame,
|
||||
uint8_t *outFrame, uint32_t width,
|
||||
uint32_t height, GifPalette *pPal )
|
||||
{
|
||||
uint32_t height, GifPalette *pPal) {
|
||||
int numPixels = (int)(width * height);
|
||||
|
||||
// quantPixels initially holds color*256 for all pixels
|
||||
@@ -473,8 +462,7 @@ public:
|
||||
// Picks palette colors for the image using simple thresholding, no dithering
|
||||
void GifThresholdImage(const uint8_t *lastFrame, const uint8_t *nextFrame,
|
||||
uint8_t *outFrame, uint32_t width, uint32_t height,
|
||||
GifPalette *pPal )
|
||||
{
|
||||
GifPalette *pPal) {
|
||||
uint32_t numPixels = width * height;
|
||||
for (uint32_t ii = 0; ii < numPixels; ++ii) {
|
||||
// if a previous color is available, and it matches the current color,
|
||||
@@ -518,8 +506,7 @@ public:
|
||||
};
|
||||
|
||||
// insert a single bit
|
||||
void GifWriteBit( GifBitStatus &stat, uint32_t bit )
|
||||
{
|
||||
void GifWriteBit(GifBitStatus &stat, uint32_t bit) {
|
||||
bit = bit & 1;
|
||||
bit = bit << stat.bitIndex;
|
||||
stat.byte |= bit;
|
||||
@@ -535,8 +522,7 @@ public:
|
||||
}
|
||||
|
||||
// write all bytes so far to the file
|
||||
void GifWriteChunk( FILE *f, GifBitStatus &stat )
|
||||
{
|
||||
void GifWriteChunk(FILE *f, GifBitStatus &stat) {
|
||||
fputc((int)stat.chunkIndex, f);
|
||||
fwrite(stat.chunk, 1, stat.chunkIndex, f);
|
||||
|
||||
@@ -545,8 +531,7 @@ public:
|
||||
stat.chunkIndex = 0;
|
||||
}
|
||||
|
||||
void GifWriteCode( FILE *f, GifBitStatus &stat, uint32_t code, uint32_t length )
|
||||
{
|
||||
void GifWriteCode(FILE *f, GifBitStatus &stat, uint32_t code, uint32_t length) {
|
||||
for (uint32_t ii = 0; ii < length; ++ii) {
|
||||
GifWriteBit(stat, code);
|
||||
code = code >> 1;
|
||||
@@ -563,8 +548,7 @@ public:
|
||||
};
|
||||
|
||||
// write a 256-color (8-bit) image palette to the file
|
||||
void GifWritePalette( const GifPalette *pPal, FILE *f )
|
||||
{
|
||||
void GifWritePalette(const GifPalette *pPal, FILE *f) {
|
||||
fputc(0, f); // first color: transparency
|
||||
fputc(0, f);
|
||||
fputc(0, f);
|
||||
@@ -582,8 +566,7 @@ public:
|
||||
void GifWriteLzwImage(FILE *f, uint8_t *image, uint32_t left,
|
||||
uint32_t top, uint32_t width,
|
||||
uint32_t height, uint32_t delay,
|
||||
GifPalette *pPal)
|
||||
{
|
||||
GifPalette *pPal) {
|
||||
// graphics control extension
|
||||
fputc(0x21, f);
|
||||
fputc(0xf9, f);
|
||||
@@ -694,8 +677,7 @@ public:
|
||||
bool GifBegin(GifWriter *writer, const char *filename,
|
||||
uint32_t width, uint32_t height,
|
||||
uint32_t delay, int32_t bitDepth = 8,
|
||||
bool dither = false )
|
||||
{
|
||||
bool dither = false) {
|
||||
(void)bitDepth;
|
||||
(void)dither; // Mute "Unused argument" warnings
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||
@@ -757,8 +739,7 @@ public:
|
||||
// this may be handy to save bits in animations that don't change much.
|
||||
bool GifWriteFrame(GifWriter *writer, const uint8_t *image,
|
||||
uint32_t width, uint32_t height,
|
||||
uint32_t delay, int bitDepth = 8, bool dither = false )
|
||||
{
|
||||
uint32_t delay, int bitDepth = 8, bool dither = false) {
|
||||
if (!writer->f) {
|
||||
return false;
|
||||
}
|
||||
@@ -783,8 +764,7 @@ public:
|
||||
// Writes the EOF code, closes the file handle, and frees temp memory used by a GIF.
|
||||
// Many if not most viewers will still display a GIF properly if the EOF code is missing,
|
||||
// but it's still a good idea to write it out.
|
||||
bool GifEnd( GifWriter *writer )
|
||||
{
|
||||
bool GifEnd(GifWriter *writer) {
|
||||
if (!writer->f) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ class GifWidget : public QDialog
|
||||
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(int borderWidth READ getBorderWidth WRITE setBorderWidth)
|
||||
Q_PROPERTY(QColor bgColor READ getBgColor WRITE setBgColor)
|
||||
|
||||
|
||||
@@ -14,7 +14,12 @@ DESTDIR = $$PWD/../bin
|
||||
CONFIG += warn_off
|
||||
|
||||
SOURCES += main.cpp
|
||||
SOURCES += frmgifwidget.cpp
|
||||
SOURCES += gifwidget.cpp
|
||||
|
||||
HEADERS += gifwidget.h
|
||||
HEADERS += frmgifwidget.h
|
||||
HEADERS += gif.h
|
||||
|
||||
FORMS += frmgifwidget.ui
|
||||
RESOURCES += main.qrc
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma execution_character_set("utf-8")
|
||||
|
||||
#include "gifwidget.h"
|
||||
#include "frmgifwidget.h"
|
||||
#include <QApplication>
|
||||
#include <QTextCodec>
|
||||
#include <QIcon>
|
||||
@@ -25,7 +25,9 @@ int main(int argc, char *argv[])
|
||||
QTextCodec::setCodecForLocale(codec);
|
||||
#endif
|
||||
|
||||
GifWidget::Instance()->show();
|
||||
frmGifWidget w;
|
||||
w.setWindowTitle("GIF录屏");
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
@@ -4,12 +4,13 @@
|
||||
#include "ui_frmmaskwidget.h"
|
||||
#include "maskwidget.h"
|
||||
#include "qdialog.h"
|
||||
#include "qtimer.h"
|
||||
#include "qdebug.h"
|
||||
|
||||
frmMaskWidget::frmMaskWidget(QWidget *parent) : QWidget(parent), ui(new Ui::frmMaskWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
MaskWidget::Instance()->setMainWidget(this);
|
||||
MaskWidget::Instance()->setDialogNames(QStringList() << "frmTest");
|
||||
QTimer::singleShot(1000, this, SLOT(initForm()));
|
||||
}
|
||||
|
||||
frmMaskWidget::~frmMaskWidget()
|
||||
@@ -18,6 +19,12 @@ frmMaskWidget::~frmMaskWidget()
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void frmMaskWidget::initForm()
|
||||
{
|
||||
MaskWidget::Instance()->setMainWidget(this->topLevelWidget());
|
||||
MaskWidget::Instance()->setDialogNames(QStringList() << "frmTest");
|
||||
}
|
||||
|
||||
void frmMaskWidget::on_pushButton_clicked()
|
||||
{
|
||||
QDialog d;
|
||||
|
||||
@@ -15,11 +15,12 @@ public:
|
||||
explicit frmMaskWidget(QWidget *parent = 0);
|
||||
~frmMaskWidget();
|
||||
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
|
||||
private:
|
||||
Ui::frmMaskWidget *ui;
|
||||
|
||||
private slots:
|
||||
void initForm();
|
||||
void on_pushButton_clicked();
|
||||
};
|
||||
|
||||
#endif // FRMMASKWIDGET_H
|
||||
|
||||
@@ -18,12 +18,12 @@
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>131</width>
|
||||
<height>23</height>
|
||||
<width>92</width>
|
||||
<height>28</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>弹出遮罩窗体</string>
|
||||
<string>弹出</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
namespace Ui {
|
||||
class frmMoveWidget;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,14 +55,6 @@ bool MoveWidget::eventFilter(QObject *watched, QEvent *event)
|
||||
return QObject::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
void MoveWidget::setWidget(QWidget *widget)
|
||||
{
|
||||
if (this->widget == 0) {
|
||||
this->widget = widget;
|
||||
this->widget->installEventFilter(this);
|
||||
}
|
||||
}
|
||||
|
||||
void MoveWidget::setLeftButton(bool leftButton)
|
||||
{
|
||||
this->leftButton = leftButton;
|
||||
@@ -72,3 +64,11 @@ void MoveWidget::setInControl(bool inControl)
|
||||
{
|
||||
this->inControl = inControl;
|
||||
}
|
||||
|
||||
void MoveWidget::setWidget(QWidget *widget)
|
||||
{
|
||||
if (this->widget == 0) {
|
||||
this->widget = widget;
|
||||
this->widget->installEventFilter(this);
|
||||
}
|
||||
}
|
||||
@@ -3,21 +3,15 @@
|
||||
|
||||
/**
|
||||
* 通用控件移动类 作者:feiyangqingyun(QQ:517216493) 2019-9-28
|
||||
* 1:可以指定需要移动的widget
|
||||
* 2:可设置是否限定鼠标左键拖动
|
||||
* 3:支持任意widget控件
|
||||
* 1. 可以指定需要移动的widget
|
||||
* 2. 可设置是否限定鼠标左键拖动
|
||||
* 3. 支持任意widget控件
|
||||
*/
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#ifdef quc
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5,7,0))
|
||||
#include <QtDesigner/QDesignerExportWidget>
|
||||
#else
|
||||
#include <QtUiPlugin/QDesignerExportWidget>
|
||||
#endif
|
||||
|
||||
class QDESIGNER_WIDGET_EXPORT MoveWidget : public QObject
|
||||
class Q_DECL_EXPORT MoveWidget : public QObject
|
||||
#else
|
||||
class MoveWidget : public QObject
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "frmpngtool.h"
|
||||
#pragma execution_character_set("utf-8")
|
||||
#include "frmpngtool.h"
|
||||
#include "ui_frmpngtool.h"
|
||||
#include "qfile.h"
|
||||
#include "qfiledialog.h"
|
||||
@@ -40,7 +41,7 @@ void frmPngTool::on_btnOk_clicked()
|
||||
|
||||
//将单个文件加入队列
|
||||
QString currentFile = ui->txtFile->text().trimmed();
|
||||
if (currentFile.isEmpty()) {
|
||||
if (!currentFile.isEmpty()) {
|
||||
files.append(currentFile);
|
||||
}
|
||||
|
||||
@@ -51,7 +52,6 @@ void frmPngTool::on_btnOk_clicked()
|
||||
QStringList filter;
|
||||
filter << "*.png";
|
||||
QStringList list = imagePath.entryList(filter);
|
||||
|
||||
foreach (QString str, list) {
|
||||
files.append(currentDir + "/" + str);
|
||||
}
|
||||
@@ -60,9 +60,10 @@ void frmPngTool::on_btnOk_clicked()
|
||||
ui->progress->setRange(0, files.count());
|
||||
ui->progress->setValue(0);
|
||||
|
||||
ui->txtMain->clear();
|
||||
int count = 0;
|
||||
foreach (QString file, files) {
|
||||
qDebug() << "current file:" << file;
|
||||
ui->txtMain->append(file);
|
||||
QImage image(file);
|
||||
image.save(file, "png");
|
||||
count++;
|
||||
@@ -70,5 +71,5 @@ void frmPngTool::on_btnOk_clicked()
|
||||
qApp->processEvents();
|
||||
}
|
||||
|
||||
qDebug() << "finsh";
|
||||
ui->txtMain->append(QString("处理完成, 共 %1 个文件").arg(files.count()));
|
||||
}
|
||||
|
||||
@@ -6,14 +6,24 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>437</width>
|
||||
<height>105</height>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLineEdit" name="txtFile"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="btnOk">
|
||||
<property name="text">
|
||||
<string>执行转换</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLineEdit" name="txtDir"/>
|
||||
</item>
|
||||
@@ -24,9 +34,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLineEdit" name="txtFile"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="btnFile">
|
||||
<property name="text">
|
||||
@@ -37,29 +44,15 @@
|
||||
<item row="2" column="0">
|
||||
<widget class="QProgressBar" name="progress">
|
||||
<property name="value">
|
||||
<number>24</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="btnOk">
|
||||
<property name="text">
|
||||
<string>执行转换</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QTextEdit" name="txtMain"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
||||
18
screenwidget/frmscreenwidget.cpp
Normal file
18
screenwidget/frmscreenwidget.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "frmscreenwidget.h"
|
||||
#include "ui_frmscreenwidget.h"
|
||||
#include "screenwidget.h"
|
||||
|
||||
frmScreenWidget::frmScreenWidget(QWidget *parent) : QWidget(parent), ui(new Ui::frmScreenWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
frmScreenWidget::~frmScreenWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void frmScreenWidget::on_pushButton_clicked()
|
||||
{
|
||||
ScreenWidget::Instance()->showFullScreen();
|
||||
}
|
||||
25
screenwidget/frmscreenwidget.h
Normal file
25
screenwidget/frmscreenwidget.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef FRMSCREENWIDGET_H
|
||||
#define FRMSCREENWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class frmScreenWidget;
|
||||
}
|
||||
|
||||
class frmScreenWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit frmScreenWidget(QWidget *parent = 0);
|
||||
~frmScreenWidget();
|
||||
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
|
||||
private:
|
||||
Ui::frmScreenWidget *ui;
|
||||
};
|
||||
|
||||
#endif // FRMSCREENWIDGET_H
|
||||
32
screenwidget/frmscreenwidget.ui
Normal file
32
screenwidget/frmscreenwidget.ui
Normal file
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>frmScreenWidget</class>
|
||||
<widget class="QWidget" name="frmScreenWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>92</width>
|
||||
<height>28</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>弹出</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -1,9 +1,8 @@
|
||||
#pragma execution_character_set("utf-8")
|
||||
|
||||
#include "screenwidget.h"
|
||||
#include "frmscreenwidget.h"
|
||||
#include <QApplication>
|
||||
#include <QTextCodec>
|
||||
#include <QIcon>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -24,7 +23,9 @@ int main(int argc, char *argv[])
|
||||
QTextCodec::setCodecForLocale(codec);
|
||||
#endif
|
||||
|
||||
ScreenWidget::Instance()->showFullScreen();
|
||||
frmScreenWidget w;
|
||||
w.setWindowTitle("屏幕截图");
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
@@ -14,5 +14,10 @@ DESTDIR = $$PWD/../bin
|
||||
CONFIG += warn_off
|
||||
|
||||
SOURCES += main.cpp
|
||||
SOURCES += frmscreenwidget.cpp
|
||||
SOURCES += screenwidget.cpp
|
||||
|
||||
HEADERS += screenwidget.h
|
||||
HEADERS += frmscreenwidget.h
|
||||
|
||||
FORMS += frmscreenwidget.ui
|
||||
|
||||
Reference in New Issue
Block a user