1. QCustomPlot 画折线图
https://blog.youkuaiyun.com/weixin_36037895/article/details/54944402
2.更新国际化:
lupdate EWhalesShaker.pro -ts Language_zh.ts
3.QTextEdit,QLineEdit删除光标前一个字符
QTextCursor cursor=ui->textEdit->textCursor();//得到当前text的光标
if(cursor.hasSelection())//如果有选中,则取消,以免受受影响
cursor.clearSelection();
cursor.deletePreviousChar();//删除前一个字符
ui->textEdit->setTextCursor(cursor);//让光标移到删除后的位置
QLineEdit 自带函数,bakspace函数删除:
lineEdit->backspace();
4.qt4 显示乱码:utf8转换为gbk
5.子窗体析构:
子窗体的构造函数中指向了父类(父窗体),但是当关闭子窗体时不会调用析构函数,只有关闭父窗体时,才会调用子窗体的析构函数,解决办法如下
在子窗体的构造函数中加上:
setAttribute(Qt::WA_DeleteOnClose);
窗口销毁问题:当我们将一个A窗口作为父窗口,B窗口作为A窗口的子窗口,如果直接关闭B窗口,由于主窗口不销毁,B窗口是不会被销毁的,会一直占内存。
QWidget *widget = new QWidget(this);
widget->setAttribute(Qt::WA_DeleteOnClose);
widget->show();
6.Qt4屏幕旋转:
(1)屏幕旋转
export QWS_DISPLAY=Transformed:Rot90 //旋转90 可以旋转0、90、180、270
想让qt支持旋转,在编译嵌入式qt的时候要加上-qt-gfx-transformed选项
(2)字体大小设置
export QWS_DISPLAY=LinuxFB:mmWidth200:mmHeight100:0 //输出设备为Linux framebuffer,尺寸定义(尺寸定义与文字大小有直接关系)
export QWS_SIZE=480x272 //屏幕大小
export QWS_DISPLAY=Transformed:Rot90:LinuxFB:mmWidth200:mmHeight100:0
(3)通过指令执行旋转
qtdemo -qws -display "LinuxFB:mmWidth200:mmHeight100:0"
qtdemo -qws -display "Transformed:Rot90"
qtdemo -qws -display "Transformed:Rot90:LinuxFB:mmWidth200:mmHeight100:0"
7.Qt5屏幕旋转:
在Qt5中取消了qws,用QPA取代之。所以在Qt4f翻转屏幕的方法“-display transfromed:Rot270“也不可以使用了哦。这个问题折腾了好久,最后发现可以将全部窗口加入QGraphicsScene中,然后窗口作为QGraphicsScene的QGraphicsProxyWidget成员,调用QGraphicsProxyWidget的setRotation方法就可以实现屏幕翻转了;
8.程序中添加输入法,子窗口中键盘无法输入:
解决qt输入法 qinputcontent 在qdialog下没响应的问题经过测试,点击输入面板,没有发应的问题,是由QDialog.exec()引起的,故切入点还是它。
从上面,可以看出QDialog默认为application modal,而要使用输入法,必有“interaction with the parent window is blocked while the dialog is open”,故使用setWindowModality(Qt::WindowModal),就可以使用输入法了.
SecondDialog seconddialog;
seconddialog.setWindowModality(Qt::WindowModal);
seccondialog.exec();
9.QDoubleValidator 直接构建失效的解决办法
https://blog.youkuaiyun.com/sheldon0227/article/details/78402735
QDoubleValidator *phoneValidator = new QDoubleValidator(0.0,1.0,1,this);
phoneValidator->setNotation(QDoubleValidator::StandardNotation);
lineEdit_setDutycycle1->setValidator(phoneValidator);
10.QT 可使用的字体:
https://blog.youkuaiyun.com/GoForwardToStep/article/details/52087397
11.QT4 使用bind function 出现问题
error: 'function' in namespace 'std' does not name a template type
解决方法:
QMAKE_CXXFLAGS += -std=c++11(在.pro文件加上)
12.解析命令行参数
https://blog.youkuaiyun.com/jcq521045349/article/details/79764090
13.qt 4支持热插拔
https://blog.youkuaiyun.com/kp339/article/details/53034215
https://blog.youkuaiyun.com/Atago_/article/details/79226268
14.获取文件默认的图标
https://blog.youkuaiyun.com/liang19890820/article/details/51821622