Qt工作笔记-SIGNAL之textChanged
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                Qt工作笔记-SIGNAL之textChanged
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.                        
                                今天學(xué)習(xí)到的東西真的很多。在查閱以前的源碼里面發(fā)現(xiàn)了textChanged這個(gè)信號(hào)。
不僅僅如此。關(guān)鍵是這讓我進(jìn)一步學(xué)會(huì)了如何看文檔;
功能動(dòng)態(tài)如下:
功能就如文檔中說(shuō)的那樣This signal is emitted whenever the text changes. The text argument is the new text.
代碼如下
widget.h
#ifndef WIDGET_H #define WIDGET_H#include <QWidget>namespace Ui { class Widget; }class Widget : public QWidget {Q_OBJECTpublic:explicit Widget(QWidget *parent = 0);~Widget();public slots:void BtnIsEnable();private:Ui::Widget *ui; };#endif // WIDGET_Hwidget.cpp
#include "widget.h" #include "ui_widget.h"Widget::Widget(QWidget *parent) :QWidget(parent),ui(new Ui::Widget) {ui->setupUi(this);ui->pushButton->setEnabled(false);connect(ui->lineEdit,SIGNAL(textChanged(QString)),this,SLOT(BtnIsEnable())); }void Widget::BtnIsEnable(){if(ui->lineEdit->text().isEmpty()){ui->pushButton->setEnabled(false);}else{ui->pushButton->setEnabled(true);} }Widget::~Widget() {delete ui; }main.cpp
#include "widget.h" #include <QApplication>int main(int argc, char *argv[]) {QApplication a(argc, argv);Widget w;w.show();return a.exec(); }總結(jié)
以上是生活随笔為你收集整理的Qt工作笔记-SIGNAL之textChanged的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
                            
                        - 上一篇: QML与C++混合编程详解
 - 下一篇: C++ STL stirng的复制比较