不同窗口之间使用信号槽

news/2024/5/19 1:34:38 标签: signal, class, ui, object
class="baidu_pl">
class="article_content clearfix">
class="htmledit_views">

不同窗口之间的信号槽,由一个窗口emit  class="tags" href="/tags/SIGNAL.html" title=signal>signal 然后在另一个窗口中用connect 响应。


editnetconfig.h

class="language-cpp">#ifndef EDITNETCONFIG_H
#define EDITNETCONFIG_H

#include <QDialog>

namespace Ui {
class EditNetConfig;
}

class EditNetConfig : public QDialog
{
    Q_OBJECT
    
public:
    explicit EditNetConfig(QWidget *parent = 0);
    ~EditNetConfig();
class="tags" href="/tags/SIGNAL.html" title=signal>signals:
    void serverIPchange(const QString &serverip);//再此声明信号
private:
    Ui::EditNetConfig *ui;
};

#endif // EDITNETCONFIG_H
然后在editnetconfig.cpp中调用

class="language-cpp">void EditNetConfig::on_buttonBox_accepted()
{
   
   QString serverip=ui->lineEdit_5->text();

   emit serverIPchange(serverip);//再此发出信号
}


然后就可以在别的窗口下connect了,

**.cpp

      connect(&editnetconfig,SIGNAL(serverIPchange(QString)),this,SLOT(serverIPchnage(QString)));



void MainWindow::serverIPchnage(const QString &serverip)
{
   qDebug()<<serverip;//此时的serverip就是你在editnetconfig.cpp中要传的参数
}



http://www.niftyadmin.cn/n/1736311.html

相关文章

QT 获得tableWidget中QComboBox的内容

QWidget * QTableWidget::cellWidget ( int row, int column ) constReturns the widget displayed in the cell in the given row and column.QWidget * widgetui->tableWidget->cellWidget(i,0);//获得widgetQComboBox *combox(QComboBox*)widget;//强制转化为QComboBo…

FT5406触摸屏驱动

1.首先&#xff0c;分析下FT5406的基本电路接口 [html] view plaincopyExternal Interface I2C/SPI: an interface for data exchange with host INT: an interrupt signal to inform the host processor that touch data is ready for read WAKE: an interru…

qt中关于设置颜色

一般的属于QWidget子类的一些控件&#xff0c;可以直接使用样式表&#xff0c;例如 label->setStyleSheet("color:white"); Qpalette类相当于对话框或是控件的调色板&#xff0c;它管理着控件或窗体的所有颜色信息&#xff0c;每个窗体或控件都包含一个QPalette对…

错误./hello: error while loading shared libraries: libQtGui.so.4: cannot open shared object file:

之前一直想在ARM 上跑qt&#xff0c;但都出现错误&#xff1a; ./hello: error while loading shared libraries: libQtGui.so.4: cannot open shared object file: No such file or directory 这主要是ARM 上的运行环境设置不当&#xff1a; 我用的是飞凌的6410 环境变量设…

const在函数前与函数后的区别

http://hi.baidu.com/joyjoytan/blog/item/e95ae850e98df364853524dc.html

LINUX内核中的xx_initcall初始化标号

LINUX内核中的xx_initcall初始化标号 田海立CSDN 2011-07-02 LINUX内核中有很多的初始化指示标志postcore_initcall(), arch_initcall(), subsys_initcall(), device_initcall(), etc. 这些起什么作用呢&#xff1f;查阅源代码&#xff08;android goldfish-2.6.29&#xff09;…

Linux应用程序开发 基础知识

原文地址&#xff1a;Linux应用程序开发 基础知识 作者&#xff1a;chipmunk_byr Linux应用程序开发本文讲述了linux应用程序开发的基本内容。值得学习&#xff01;Copyright © 2006 本文遵从GNU 的自由文档许可证(Free Documentation License)的条款&#xff0c;欢迎转载…

set_fs get_fs

其实内核里面也可以用系统调用的&#xff0c;直接用read/write是可以的。但要注意几个问题&#xff1a; 一个是要记得编译的时候加上-D__KERNEL_SYSCALLS__ 另外源文件里面要#include <linux/unistd.h> 如果报错&#xff0c;很可能是因为使用的缓冲区超过了用户空…