关于qt5:案例分享Qt政务标签设计器标签排版软件定制与打印

41次阅读

共计 4389 个字符,预计需要花费 11 分钟才能阅读完成。

需要
  1. 标签设计器;
  2. 具备文字排版性能;
  3. 反对六种排版格局;
  4. 排版后能够输入打印(demo 中不蕴含);
  5. 排版后能够输入标签的指定协定文本 FBD 格局;
  6. 能够调整对应标签的一些地位,x,y,宽度,高度,横向间距,纵向间距;
  7. 反对排版后的标签预览;
  8. 标签排版文本谬误提醒;

Demo v1.6.0
  在这里插入图片形容
  在这里插入图片形容
  在这里插入图片形容
  在这里插入图片形容
  在这里插入图片形容
  在这里插入图片形容
  在这里插入图片形容

体验下载地址
  CSDN(粉丝免积分下载):https://download.csdn.net/dow…
  QQ 群:1047134658(点击“文件”搜寻“labelDesigner”,群内与博文同步更新)

模块化
  模块化设计构架:
  在这里插入图片形容

外围源码头文件
Widget.h

ifndef WIDGET_H

define WIDGET_H

include <QTextCodec>

include <QWidget>

include <QAbstractButton>

include <QFileDialog>

include <QMessageBox>

include “LabelWidget.h”

namespace Ui {
class Widget;
}

class Widget : public QWidget
{

Q_OBJECT

public:

explicit Widget(QWidget *parent = 0);
~Widget();

protected:

void initControls();
void createLabelWidgets();
void updateLabelWidgets();
void updateScale();
QStringList parseNames(QString content);

protected slots:

void slot_updateScale();
void slot_buttonClicked(QAbstractButton *pAbstractButton);

protected:

void resizeEvent(QResizeEvent *event);

private slots:

void on_spinBox_x_valueChanged(int arg1);
void on_spinBox_y_valueChanged(int arg1);
void on_spinBox_xNumber_valueChanged(int arg1);
void on_spinBox_yNumber_valueChanged(int arg1);
void on_spinBox_labelWidth_valueChanged(int arg1);
void on_spinBox_labelHeight_valueChanged(int arg1);
void on_doubleSpinBox_scale_valueChanged(double arg1);
void on_spinBox_labelVerticallSpace_valueChanged(int arg1);
void on_spinBox_labelHorizalSpace_valueChanged(int arg1);
void on_textEdit_names_textChanged();
void on_pushButton_createLabel_clicked();

void on_pushButton_export_clicked();

private:

Ui::Widget *ui;

private:

QList<LabelWidget *> _listLabelWidget;
QStringList _listNames;
QStringList _listErrorNames;

int _xMM;
int _yMM;
int _widthMM;
int _heightMM;
int _widthSpace;
int _heightSpace;
int _widthNumber;
int _heightNumber;
bool _firstRotate180;
bool _secondRotate180;
bool _showFontVertical;
int _fontPt;

};

endif // WIDGET_H

ScreenManager.h

ifndef SCREENMANAGER_H

define SCREENMANAGER_H

include <QObject>

class ScreenManager : public QObject
{

Q_OBJECT

public:

explicit ScreenManager(QObject *parent = nullptr);

signals:

public slots:

public:

static float getScreenWidthMM();
static float getScreenHeightMM();
static float getScreenWidthMM(int width);
static float getScreenHeightMM(int height);
static int getWidth();
static int getHeight();
static int getWidth(float widthMM);
static int getHeight(float heightMM);

private:

static float inchToMMScale;

};

endif // SCREENMANAGER_H

LabelWidget.h

ifndef LABELWIDGET_H

define LABELWIDGET_H

include <QWidget>

include <QTimer>

include <QtMath>

namespace Ui {
class LabelWidget;
}

class LabelWidget : public QWidget
{

Q_OBJECT

public:

explicit LabelWidget(QWidget *parent = 0);
~LabelWidget();

public:

float getXMM() const;
float getYMM() const;
float getLabelWidthMM() const;
float getLabelHeightMM() const;
int getVerticalLabelsNumber() const;
int getHorizalLabelNumber() const;
float getScale() const;
float getLabelHorizalSpaceMM() const;
float getLabelVerticalSpaceMM() const;
QStringList getListName() const;
bool getFirstLabelRotate180() const;
bool getSecondLabelRotate180() const;
int getFontPt() const;
bool getShowFontVertical() const;

public:

void setXMM(float xMM);
void setYMM(float yMM);
void setLabelWidthMM(float labelWidthMM);
void setLabelHeightMM(float labelHeightMM);
void setVerticalLabelsNumber(int verticalLabelsNumber);
void setHorizalLabelNumber(int horizalLabelNumber);
void setScale(float scale);
void setLabelHorizalSpaceMM(float labelHorizalSpaceMM);
void setLabelVerticalSpaceMM(float labelVerticalSpaceMM);
void setLabelsNames(QStringList listName);
void setFirstLabelRotate180(bool firstLabelRotate180);
void setSecondLabelRotate180(bool secondLabelRotate180);
void setFontPt(int fontPt);
void setShowFontVertical(bool showFontVertical);

protected:

void initControls();
void updateSize();

protected slots:

void slot_initScale();       // 用于躲避初始化地位偏差

protected:

void paintEvent(QPaintEvent *event);
void resizeEvent(QResizeEvent *event);

protected:

void drawBackground(QPainter *painter);
void drawLabelBorder(QPainter *painter);
void drawLabel(QPainter *painter);

private:

Ui::LabelWidget *ui;

private:

QColor _backgroundColor;
QColor _labelBorderColor;
int _labelBorderWidth;

float _labelWidthMM;
float _labelHeightMM;
float _labelHorizalSpaceMM;
float _labelVerticalSpaceMM;
int _verticalLabelsNumber;
int _horizalLabelNumber;
float _xMM;
float _yMM;
float _pageWidthMM;
float _pageHeightMM;
float _scale;

int _x;
int _y;
int _labelWidth;
int _labelHeight;
int _pageWidth;
int _pageHeight;
int _labelHorizalSpace;
int _labelVerticalSpace;

bool _firstLabelRotate180;
bool _secondLabelRotate180;
int _fontPt;
bool _showFontVertical;

QStringList _listName;

};

endif

若该文为原创文章,转载请注明原文出处
本文章博客地址:https://hpzwl.blog.csdn.net/a…

正文完
 0