zoukankan      html  css  js  c++  java
  • Qt connectSlotsByName(QObject *)(转)

    我们编辑ui文件时候 可以这样使用槽函数, on_objectName_signal(args) ;  非常简便, 文档说明是下面

    1 void QMetaObject::connectSlotsByName ( QObject * object ) [static]
    2 Searches recursively for all child objects of the given object, and connects matching signals from them to slots of object that follow the following form:
    3 
    4 void on_<object name>_<signal name>(<signal parameters>);
    5 Let's assume our object has a child object of type QPushButton with the object name button1. The slot to catch the button's clicked() signal would be:
    6 
    7 void on_button1_clicked(); 

    尽管这里的button1是ui对象下的,它也是可以这样使用的,相当于系统自动建立好了连接。

    它等同于在MainWindow。cpp中:connect(ui->button1, &QPushButton ::clicked, this, on_button1_clicked);

    ————————————————
    版权声明:本文为CSDN博主「liulihuo_gyh」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/liulihuo_gyh/article/details/45535675

  • 相关阅读:
    回调函数
    zoj 2104
    zoj 1760
    ppt 图的基本算法 dfs
    zoj 2110 Tempter of the Bone
    优先队列 priority_queue 55 nyist
    STL的队列和栈简单使用
    poj 2246 递归 zoj 1094
    nyist 8 set的应用
    bailian 2694
  • 原文地址:https://www.cnblogs.com/Stephen-Qin/p/13149507.html
Copyright © 2011-2022 走看看