赞
踩
#将依赖库拷贝至执行程序路径
#!/bin/sh
#可执行程序名
appname="FLS_400"
#目标文件夹
dst="./"
#利用 ldd 提取依赖库的具体路径
liblist=$(ldd $appname | awk '{ if (match($3,"/")){ printf("%s "), $3 } }')
#目标文件夹的检测
if [ ! -d $dst ];then
mkdir $dst
fi
#/bin/bash
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/home//fzl/single/build-Tforce/release
cd /home//fzl/single/build/release
./FLS_400
#include <QtCore> #include <QtGui> #include <QDesktopWidget> class QtHelper: public QObject { public: //设置为开机启动 static void AutoRunWithSystem(bool IsAutoRun, QString AppName, QString AppPath) { QSettings *reg = new QSettings( "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat); if (IsAutoRun) { reg->setValue(AppName, AppPath); } else { reg->setValue(AppName, ""); } } //设置编码为UTF8 static void SetUTF8Code() { #if (QT_VERSION <= QT_VERSION_CHECK(5,0,0)) QTextCodec *codec = QTextCodec::codecForName("UTF-8"); QTextCodec::setCodecForLocale(codec); QTextCodec::setCodecForCStrings(codec); QTextCodec::setCodecForTr(codec); #endif } //设置皮肤样式 static void SetStyle(const QString &styleName) { QFile file(QString(":/image/%1.css").arg(styleName)); file.open(QFile::ReadOnly); QString qss = QLatin1String(file.readAll()); qApp->setStyleSheet(qss); qApp->setPalette(QPalette(QColor("#F0F0F0"))); } //加载中文字符 static void SetChinese() { QTranslator *translator = new QTranslator(qApp); translator->load(":/image/qt_zh_CN.qm"); qApp->installTranslator(translator); } //判断是否是IP地址 static bool IsIP(QString IP) { QRegExp RegExp("((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)"); return RegExp.exactMatch(IP); } //延时 static void Sleep(int sec) { QTime dieTime = QTime::currentTime().addMSecs(sec); while ( QTime::currentTime() < dieTime ) { QCoreApplication::processEvents(QEventLoop::AllEvents, 100); } } //窗体居中显示 static void FormInCenter(QWidget *frm) { int frmX = frm->width(); int frmY = frm->height(); QDesktopWidget w; int deskWidth = w.width(); int deskHeight = w.height(); QPoint movePoint(deskWidth / 2 - frmX / 2, deskHeight / 2 - frmY / 2); frm->move(movePoint); } //设置应用程序的字体 static void SetFont() { QFont font("Courier", 10, QFont::Normal, false); QApplication::setFont(font); } //设置窗口 void SetWindowFlags(Qt::WindowFlags type) { setWindowFlags(Qt::WindowCloseButtonHint); //只要关闭按钮 Qt::WindowStaysOnTopHint: //总在最上面的窗口 Qt::CustomizeWindowHint: //自定义窗口标题栏,以下标志必须与这个标志一起使用才有效,否则窗口将有默认的标题栏 Qt::WindowTitleHint //显示窗口标题栏 Qt::WindowSystemMenuHint //显示系统菜单 Qt::WindowMinimizeButtonHint //显示最小化按钮 Qt::WindowMaximizeButtonHint //显示最大化按钮 Qt::WindowMinMaxButtonsHint //显示最小化按钮和最大化按钮 Qt::WindowCloseButtonHint //显示关闭按钮 Qt::FrameWindowHint:没有边框的窗口(常用) setWindowFlags(Qt::Tool | Qt::X11BypassWindowManagerHint)//隐藏任务栏显示 //关闭按钮实现的功能 { hide(); //进行界面隐藏,但是显示托盘,可通过点击托盘实现界面的重新显示 quit(); //退出系统 } } //绘制背景图片并且实现圆角效果(常用),重写绘画事件 void paintEvent(QPaintEvent *) { QPainter painter(this); QBrush brush; brush.setTextureImage(QImage(background_image)); //背景图片 painter.setBrush(brush); painter.setPen(Qt::black); //边框色 painter.drawRoundedRect(this->rect(), 5, 5); //圆角5像素 } //设置字体(字体风格,包括类型、大小、是否加粗、是否斜体等!) void SetFont(QWidget *Wgt) { QFont font = this->font(); font.setFamily("Courier"); //字体名称 font.setPixelSize(16); //字体点大小 font.setPointSize(18); //字体像素大小 font.setBold(true); //是否加粗 font.setItalic(true); //是否斜体 font.setUnderline(true); //是否下划线 Wgt->setFont(font); //也可使用:setStyleSheet("text-align:center; font-size:18px; font-weight:bold; font-style:Courier; color:white; "); //setAlignment(Qt::AlignCenter); //设置对齐方式 } //全屏显示与还原 { showFullScreen();//遮挡任务栏 showMaximized() ;//遮挡任务 } void showMaximize()//不遮挡任务栏 { //若已经最大化 if(m_IsMax) { //恢复界面位置,并设置按钮图标为最大化图标,提示“最大化” this->setGeometry(location); max_button->setIcon(QIcon("maxbtn")); max_button->setToolTip(tr("最大化")); } else { //设定当前界面的位置,还原时使用 location = this->geometry(); //获取桌面位置,设置为最大化,并设置按钮图标为还原图标,提示“还原” QDesktopWidget *desk = QApplication::desktop(); this->setGeometry(desk->availableGeometry()); max_button->setIcon(QIcon("restorbtn")); max_button->setToolTip(tr("restor")); } m_IsMax= !m_IsMax; } //QLineEdit内设置图片(QLineEdit::LeadingPosition 在左侧有图片,QLineEdit::TrailingPosition 在右侧有图片) void SetPicToLineEdit()//将带有图片的 action 添加到lineedit中即可 { QAction *searchAction = new QAction(m_DateUi->m_StartlineEdit); searchAction->setIcon(QIcon("Image/MainFrm/zc.png")); m_DateUi->m_StartlineEdit->addAction(searchAction, QLineEdit::LeadingPosition); } { //设置label颜色 QPalette pe; pe.setColor(QPallette::WindowText,Qt::red); label0->setPalette(pe); label0->setText(tr("请输入命令")); //设置dialog背景图片 this->setAutoFillBackground(true); QPalette palette; palette.setBrush(QPalette::Background, QBrush(QPixmap("2.jpg"))); setPalette(palette); //设置scrollArea scrollArea = new QScrollArea; scrollArea->setBackgroundRole(QPalette::Base); scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); scrollArea->setWidget(recv); //设置UTF8 QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); } } 堆上创建的对象由于父窗口(对象)没释放,只会加载到对象树中不会直接释放,可以通过设置属性函数setAttribute()和值55让其直接释放,不用等到父对象释放才释放
windows 程序崩溃不弹窗设置 利用 批处理带起服务(弹窗后不关闭批处理带不起程序)
LONG WINAPI HandleDefaultExceptionInfo(PEXCEPTION_POINTERS pExceptPtrs)
{
return EXCEPTION_EXECUTE_HANDLER;
}
int main()
{
SetErrorMode(SEM_NOGPFAULTERRORBOX);
SetUnhandledExceptionFilter(HandleDefaultExceptionInfo);//截断未处理异常防止错误对话框弹出
}
linux qtcreator 报错
: error: cannot find -lGL: No such file or directory
解决:udo apt-get install mesa-common-dev
QT字体滚动实现 #ifndef TEXTSCROLL_H #define TEXTSCROLL_H #include <QObject> #include <QWidget> #include <QTimer> #include <QPainter> #include <QFontMetrics> #include <QResizeEvent> class textScroll : public QWidget { Q_OBJECT private: QTimer* timer; //时间定时器 QRgb textColor; QString m_text; QString m_showText; QFont font; int m_ms; int m_pixelSize; int m_moveOffset; int m_moveSize; int blankSuffix; float speed; //滑动速度,值越大越快 void paintEvent(QPaintEvent *event); void resizeEvent(QResizeEvent *event); public: explicit textScroll(QWidget *parent = 0); //qRgb(int r, int g, int b) void setDelay(int ms,int pixelSize); //设置滚动延迟,多少ms滚动多少像素点 void setText(QString text,QRgb textColor,float speed=0.70,int blankSuffix=20); //设置字体,调用该函数后,将会自动启动定时器来滚动字幕 void restart(); signals: public slots: void timeOut(); }; #endif // TEXTSCROLL_H =========================================================== cpp文件 #include "textscoll.h" #include <QDebug> textScroll::textScroll( QWidget *parent) : QWidget(parent) { timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(timeOut())); } void textScroll::timeOut() { qDebug()<<m_moveOffset<<m_moveSize; m_moveOffset+=m_pixelSize; if(m_moveOffset>m_moveSize) { m_moveOffset= 0; } update(); } void textScroll::resizeEvent(QResizeEvent *event) { font.setPixelSize(event->size().height()*0.75); m_showText = m_text; QFontMetrics metrics(font); int char_w = metrics.width(" "); setDelay(30,char_w*speed); int blankLine =width()/char_w+1; for(int i=0;i<blankLine;i++) { m_showText.insert(0," "); } m_moveSize=metrics.width(m_showText)+blankSuffix; m_moveOffset=0; update(); } void textScroll::paintEvent(QPaintEvent *event) { QPainter painter(this); painter.setFont(font); painter.setPen(QColor(120,120,120)); painter.drawRect(QRect(0,0,width()-1,height()-1)); painter.setPen(QColor(textColor)); painter.drawText(QRect(-m_moveOffset,0,width()-1+m_moveOffset,height()-1), Qt::AlignVCenter|Qt::AlignLeft,m_showText); } void textScroll::setDelay(int ms,int pixelSize) //设置滚动延迟,多少ms滚动多少像素点 { this->m_ms=ms; this->m_pixelSize=pixelSize; } void textScroll::setText(QString text, QRgb textColor, float speed, int blankSuffix) //设置字体 { this->blankSuffix = blankSuffix; this->speed = speed; font.setFamily("Microsoft Yahei"); font.setPixelSize(height()*0.75); this->textColor = textColor; m_text = text; m_showText = m_text; QFontMetrics metrics(font); int char_w = metrics.width(" "); setDelay(50,char_w*speed); int blankLine =width()/char_w+2; for(int i=0;i<blankLine;i++) { m_showText.insert(0," "); } m_moveSize=metrics.width(m_showText)+blankSuffix; m_moveOffset=0; if(!timer->isActive()) { if(m_ms) { timer->start(m_ms); } } } void textScroll::restart() { m_moveOffset=0; update(); }
CSS文件如下 (stylesheet.css) QWidget#frmLogin,QWidget#frmPopup,QWidget#frmHostInfo,QWidget#frmLogout,QWidget#frmConfig,QWidget#frmData,QWidget#frmDefence,QWidget#frmHost,QWidget#frmMain,QWidget#frmPwd,QWidget#frmSelect,QWidget#frmMessageBox{ border:1px solid #1B89CA; border-radius:0px; } .QFrame{ border:1px solid #5CACEE; border-radius:5px; } QWidget#widget_title{ background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #1B89CA, stop:1 #1077B5); } QLabel#lab_Ico,QLabel#lab_Title{ border-radius:0px; color: #F0F0F0; background-color:rgba(0,0,0,0); border-style:none; } QLineEdit { border: 1px solid #5CACEE; border-radius: 5px; padding: 2px; background: none; selection-background-color: #1B89CA; } QLineEdit[echoMode="2"] { lineedit-password-character: 9679; } .QGroupBox{ border: 1px solid #5CACEE; border-radius: 5px; } .QPushButton{ border-style: none; border: 0px; color: #F0F0F0; padding: 5px; min-height: 20px; border-radius:5px; background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #1B89CA, stop:1 #1077B5); } .QPushButton[focusPolicy="0"] { border-style: none; border: 0px; color: #F0F0F0; padding: 0px; min-height: 10px; border-radius:3px; background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #1B89CA, stop:1 #1077B5); } .QPushButton:hover{ background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #5CACEE, stop:1 #4F94CD); } .QPushButton:pressed{ background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #1B89CA, stop:1 #1077B5); } QPushButton#btnMenu,QPushButton#btnMenu_Min,QPushButton#btnMenu_Max,QPushButton#btnMenu_Close{ border-radius:0px; color: #F0F0F0; background-color:rgba(0,0,0,0); border-style:none; } QPushButton#btnMenu:hover,QPushButton#btnMenu_Min:hover,QPushButton#btnMenu_Max:hover{ background-color: qlineargradient(spread:pad, x1:0, y1:1, x2:0, y2:0, stop:0 rgba(25, 134, 199, 0), stop:1 #5CACEE); } QPushButton#btnMenu_Close:hover{ background-color: qlineargradient(spread:pad, x1:0, y1:1, x2:0, y2:0, stop:0 rgba(238, 0, 0, 128), stop:1 rgba(238, 44, 44, 255)); } QCheckBox { spacing: 2px; } QCheckBox::indicator { width: 20px; height: 20px; } QCheckBox::indicator:unchecked { image: url(:/image/checkbox_unchecked.png); } QCheckBox::indicator:checked { image: url(:/image/checkbox_checked.png); } QRadioButton { spacing: 2px; } QRadioButton::indicator { width: 15px; height: 15px; } QRadioButton::indicator::unchecked { image: url(:/image/radio_normal.png); } QRadioButton::indicator::checked { image: url(:/image/radio_selected.png); } QComboBox,QDateEdit{ border-radius: 3px; padding: 1px 10px 1px 5px; border: 1px solid #5CACEE; } QComboBox::drop-down,QDateEdit::drop-down { subcontrol-origin: padding; subcontrol-position: top right; width: 15px; border-left-width: 1px; border-left-style: solid; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-left-color: #5CACEE; } QComboBox::down-arrow,QDateEdit::down-arrow { image: url(:/image/array_down.png); } QMenu { background-color:#F0F0F0; margin: 2px; } QMenu::item { padding: 2px 12px 2px 12px; } QMenu::indicator { width: 13px; height: 13px; } QMenu::item:selected { color: #FFFFFF; background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #1B89CA, stop:1 #1077B5); } QMenu::separator { height: 1px; background: #5CACEE; } QProgressBar { border-radius: 5px; text-align: center; border: 1px solid #5CACEE; } QProgressBar::chunk { width: 5px; margin: 0.5px; background-color: #1B89CA; } QSlider::groove:horizontal,QSlider::add-page:horizontal { background: #808080; height: 8px; border-radius: 3px; } QSlider::sub-page:horizontal { height: 8px; border-radius: 3px; background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #1B89CA, stop:1 #1077B5); } QSlider::handle:horizontal { width: 13px; margin-top: -3px; margin-bottom: -3px; border-radius: 6px; background: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5,stop:0.6 #F0F0F0, stop:0.778409 #5CACEE); } QSlider::handle:horizontal:hover { background: qradialgradient(spread: pad, cx: 0.5, cy: 0.5, radius: 0.5, fx: 0.5, fy: 0.5, stop: 0.6 #F0F0F0,stop:0.778409 #1B89CA); } QSlider::groove:vertical,QSlider::sub-page:vertical { background:#808080; width: 8px; border-radius: 3px; } QSlider::add-page:vertical { width: 8px; border-radius: 3px; background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #1B89CA, stop:1 #1077B5); } QSlider::handle:vertical { height: 14px; margin-left: -3px; margin-right: -3px; border-radius: 6px; background: qradialgradient(spread: pad, cx: 0.5, cy: 0.5, radius: 0.5, fx: 0.5, fy: 0.5, stop: 0.6 #F0F0F0, stop:0.778409 #5CACEE); } QSlider::handle:vertical:hover { background: qradialgradient(spread: pad, cx: 0.5, cy: 0.5, radius: 0.5, fx: 0.5, fy: 0.5, stop: 0.6 #F0F0F0,stop:0.778409 #1B89CA); } QScrollBar:vertical { width:10px; background-color:rgba(0,0,0,0%); padding-top:10px; padding-bottom:10px; } QScrollBar:horizontal { height:10px; background-color:rgba(0,0,0,0%); padding-left:10px; padding-right:10px; } QScrollBar::handle:vertical { width:10px; background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #5CACEE, stop:1 #4F94CD); } QScrollBar::handle:horizontal { height:10px; background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #5CACEE, stop:1 #4F94CD); } QScrollBar::handle:vertical:hover { width:10px; background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #1B89CA, stop:1 #1077B5); } QScrollBar::handle:horizontal:hover { height:10px; background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #1B89CA, stop:1 #1077B5); } QScrollBar::add-line:vertical { height:10px; width:10px; subcontrol-position: bottom; subcontrol-origin: margin; border-image:url(:/image/add-line_vertical.png); } QScrollBar::add-line:horizontal { height:10px; width:10px; subcontrol-position: right; subcontrol-origin: margin; border-image:url(:/image/add-line_horizontal.png); } QScrollBar::sub-line:vertical { height:10px; width:10px; subcontrol-position: top; subcontrol-origin: margin; border-image:url(:/image/sub-line_vertical.png); } QScrollBar::sub-line:horizontal { height:10px; width:10px; subcontrol-position: left; subcontrol-origin: margin; border-image:url(:/image/sub-line_horizontal.png); } QScrollBar::add-page:vertical,QScrollBar::sub-page:vertical { width:10px; background: #C0C0C0; } QScrollBar::add-page:horizontal,QScrollBar::sub-page:horizontal { height:10px; background: #C0C0C0; } QScrollArea { border: 0px ; } QTreeView,QListView,QTableView{ border: 1px solid #5CACEE; selection-background-color: #1B89CA; selection-color: #F0F0F0; } QTableView::item:selected, QListView::item:selected, QTreeView::item:selected { color: #F0F0F0; background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #1B89CA, stop:1 #1077B5); } QTableView::item:hover, QListView::item:hover, QTreeView::item:hover { color: #F0F0F0; background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #5CACEE, stop:1 #4F94CD); } QTableView::item, QListView::item, QTreeView::item { padding: 5px; margin: 0px; } QHeaderView::section { padding:3px; margin:0px; color:#F0F0F0; border: 1px solid #F0F0F0; background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #5CACEE, stop:1 #4F94CD); } QTabBar::tab { border-bottom-left-radius:0px; border-bottom-right-radius:0px; color: #F0F0F0; min-width: 60px; min-height: 20px; padding: 3px 8px 3px 8px; margin:1px; background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #5CACEE, stop:1 #4F94CD); } QTabBar::tab:selected, QTabBar::tab:hover { background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #1B89CA, stop:1 #1077B5); } QStatusBar::item { border: 1px solid #5CACEE; border-radius: 3px; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。