主页 > 互联网  > 

QT-对象树

QT-对象树

思维导图

写1个Widget窗口,窗口里面放1个按钮,按钮随便叫什么 创建2个Widget对象 Widget w1,w2 w1.show() w2不管 要求:点击 w1.btn ,w1隐藏,w2显示 点击 w2.btn ,w2隐藏,w1 显示

#include <QApplication> #include <QDebug> #include <QLabel> #include <QPalette> #include <QLineEdit> #include <QPushButton> #include <QHBoxLayout> #include <QLayout> #include <QWidget> #include <QTextEdit> using namespace std; class Widget:public QWidget{ QPushButton* btn; Widget* other; public: Widget() :btn(NULL),other(NULL) { btn = new QPushButton(this); btn->setText("按钮"); QObject::connect(btn,&QPushButton::clicked,this,&Widget::Event); } void Event() { this->hide(); other->show(); } void operator==(Widget& other) { this->other=&other; other.other=this; } }; int main(int argc,char** argv) { QApplication app(argc,argv);//QT应用程序的入口类 Widget w1,w2; w1==w2; w1.show(); return app.exec(); }

标签:

QT-对象树由讯客互联互联网栏目发布,感谢您对讯客互联的认可,以及对我们原创作品以及文章的青睐,非常欢迎各位朋友分享到个人网站或者朋友圈,但转载请说明文章出处“QT-对象树