随笔分类 -  QT

摘要:例如: 在一个界面中有16个按钮(QPushButton)和4个(QRadioButton)这20个物件的SIGNAL(clicked(bool))都连接(connect)到同一个按键的处理槽中(void get_keyvalue(bool)) 那么就需要在get_keyvalue这个槽中把这些信号 阅读全文
posted @ 2016-03-18 13:55 luxiaolai 阅读(723) 评论(0) 推荐(0)
摘要:QTableWidgetSelectionRange list=QTableWidgetSelectionRange(1,0,2,2);// ui->tableWidget->selectAll(); // QTableWidgetSelectionRangerange(0,0,rowCou... 阅读全文
posted @ 2015-12-28 15:15 luxiaolai 阅读(815) 评论(0) 推荐(0)
摘要:非阻塞延时:void GreenPass3::delaymsec(int msec) { QTime dieTime = QTime::currentTime().addMSecs(msec); while( QTime::currentTime() < dieTime ) QCoreApplic... 阅读全文
posted @ 2015-12-21 14:42 luxiaolai 阅读(1824) 评论(0) 推荐(0)
摘要:QTime aaa=QTime::currentTime(); qDebug(QString::number(aaa.msec()).toAscii()); 阅读全文
posted @ 2015-12-15 14:12 luxiaolai 阅读(1082) 评论(0) 推荐(0)
摘要:设置QWidget的Qt::WindowModality属性为Qt::WindowModal和Qt::ApplicationModal,发现窗体仍然不会模态,网上查了一下,有人说改属性只对window有效,找了很多方法,验证原因是因为我的QWidget有Parent,如果构造时设置Parent为NU... 阅读全文
posted @ 2015-09-09 10:03 luxiaolai 阅读(2270) 评论(0) 推荐(0)
摘要:// 1.正常 btnNormal_ = new QPushButton("Normal Button", this); // 2.可停驻 btnCheck_ = new QPushButton("Toggle Button", this); btnCheck_->setCheckable(TRUE... 阅读全文
posted @ 2015-08-24 09:01 luxiaolai 阅读(1214) 评论(0) 推荐(0)
摘要:setWindowFlags (Qt::CustomizeWindowHint)setWindowFlags (Qt::FramelessWindowHint)两个函数都可以去掉标题栏,区别是第一个可以鼠标缩放窗口 阅读全文
posted @ 2015-08-24 09:00 luxiaolai 阅读(970) 评论(0) 推荐(0)
摘要:Qt窗体关闭时,如何自动销毁窗体类对象要对你的窗口设置WA_DeleteOnClose属性,默认的情况下关闭窗口仅仅意味着隐藏它 ImgWindow1->setAttribute(Qt::WA_DeleteOnClose, true); 阅读全文
posted @ 2015-07-31 10:42 luxiaolai 阅读(1734) 评论(0) 推荐(0)
摘要:Qt:禁止qDebug的输出在工程的.pro文件里加上以下编译批令即可:DEFINES += QT_NO_DEBUG_OUTPUT 阅读全文
posted @ 2015-06-29 17:08 luxiaolai 阅读(593) 评论(0) 推荐(0)
摘要:keyPressEvent()部分代码:if (e->key() == Qt::Key_A && e->isAutoRepeat()){ if (!mPressFlag_A) { mKeyDirection.x = -1;//这里就是真正按键按下触发的事件 } mPressFlag_A = tru... 阅读全文
posted @ 2015-05-22 13:29 luxiaolai 阅读(2201) 评论(0) 推荐(0)
摘要:Qt 读取txt文本乱码问题2015-05-20 15:46方法一:使用QString的fromLocal8Bit()函数复制代码QFile txtfile(filePath); QString tmpStr; if(txtfile.open(QIODevice::ReadOnly)) { ... 阅读全文
posted @ 2015-05-22 13:16 luxiaolai 阅读(4873) 评论(0) 推荐(0)
摘要:focusPolicy一个QWidget获得焦点的方式受 focusPolicy 控制 Qt::TabFocus 通过Tab键获得焦点 Qt::ClickFocus 通过被单击获得焦点 Qt::StrongFocus 可通过上面两种方式获得焦点 Qt::NoFocus 不能通过上两种方式获得焦点(默... 阅读全文
posted @ 2015-04-13 16:29 luxiaolai 阅读(1793) 评论(0) 推荐(0)
摘要:表 1. 伪状态列表伪状态 描述:checked button部件被选中:disabled 部件被禁用:enabled 部件被启用:focus 部件获得焦点:hover 鼠标位于部件上:indeterminate checkbox或radiobutton被部分选中:off 部件可以切换,且处于off... 阅读全文
posted @ 2015-04-09 14:02 luxiaolai 阅读(1764) 评论(0) 推荐(0)
摘要:01.class KeyButton : public QPushButton 02.{ 03. Q_OBJECT 04.public: 05. explicit KeyButton(QWidget *parent = 0) : QPushButton(parent), 06. pauseMsecs... 阅读全文
posted @ 2015-04-01 16:52 luxiaolai 阅读(352) 评论(0) 推荐(0)
摘要:1 增加头文件 #include "QTextCodec"2 在文件中增加如下内容 QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForCStrings(QTextCodec::co... 阅读全文
posted @ 2015-03-17 11:04 luxiaolai 阅读(263) 评论(0) 推荐(0)
摘要://重启软件 void MainWindow::on_pushButton_UI_reboot_clicked(){ //方式1 需要主函数中事件循环判断 //qApp->exit(773); //重启代码,773 = 'r'+'e'+'s'+'t'+'a'+'r'+'t' ==>restart//... 阅读全文
posted @ 2015-02-25 14:22 luxiaolai 阅读(864) 评论(0) 推荐(0)
摘要:第一部分:关于sleep函数,我们先来看一下他的作用:sleep函数是使调用sleep函数的线程休眠,线程主动放弃时间片。当经过指定的时间间隔后,再启动线程,继续执行代码。sleep函数并不能起到定时的作用,主要作用是延时。在一些多线程中可能会看到sleep(0);其主要目的是让出时间片。sleep... 阅读全文
posted @ 2015-01-29 14:00 luxiaolai 阅读(16491) 评论(0) 推荐(0)
摘要:lib/libQtGui.so: undefined reference to `ts_read_raw'/lib/libQtGui.so: undefined reference to `ts_open'/lib/libQtGui.so: undefined reference to `ts_fd... 阅读全文
posted @ 2014-05-23 15:53 luxiaolai 阅读(6066) 评论(0) 推荐(1)
摘要:/*************************************************Function: hexStringtoByteArray()Description: 十六进制字串转化为十六进制编码Calls: formatString()Called By:Input: he... 阅读全文
posted @ 2014-05-14 16:44 luxiaolai 阅读(12755) 评论(1) 推荐(0)
摘要:/*************************************************Function: formatString()Description: 将十六进制字串每字节中间加空格分隔Calls:Called By:hexStringtoByteArray()Input: o... 阅读全文
posted @ 2014-05-14 16:00 luxiaolai 阅读(976) 评论(0) 推荐(0)