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

  • 相关阅读:
    数字类型和字符串类型
    python 基础-----数字,字符串,列表,字典类型简单介绍
    Pycharm快捷键的使用
    学习PYTHON之路, DAY 3
    购物车
    三级菜单
    模拟登录
    学习PYTHON之路, DAY 2
    学习PYTHON之路, DAY 1
    SSFOJ P1453 子序列(一) 题解
  • 原文地址:https://www.cnblogs.com/Stephen-Qin/p/13149507.html
Copyright © 2011-2022 走看看