简体   繁体   English

Qt C ++信号插槽连接,用于对象之间的数据交换

[英]qt c++ signal slot connections for data exchange between objects

I´m stuck on the following problem: 我陷入了以下问题:

I have a QWidget named PBVars with lots of line-edits that are filled in by a read-routine. 我有一个名为PBVars的QWidget,其中包含许多行编辑,这些行编辑由读取例程填充。 Now I want to give the user a chance to edit some fields without having to delete all entries. 现在,我想让用户有机会编辑某些字段,而不必删除所有条目。 For that I thought to open a new dialog (named EGG) and to copy all the data into EGG. 为此,我想打开一个新对话框(名为EGG)并将所有数据复制到EGG中。 Now the user can change data, click "SaveValuesToGUI" and the values are saved back to PBVars. 现在,用户可以更改数据,单击“ SaveValuesToGUI”,然后将值保存回PBVars。 This is may idea. 这可能是想法。

I managed to read all data from PBVars -> EGG. 我设法从PBVars-> EGG中读取了所有数据。 But I´m stuck in creating a signal-slot-connection back from EGG -> PBVars. 但是我被困在从EGG-> PBVars创建信号插槽连接的过程中。

PBVars.h : PBVars.h:

...    
EGG *   egg ;

PBVars.cpp : PBVars.cpp:

PBVars::PBVars(QWidget *parent) :
Tab(parent), ui(new Ui::PBVars)
{
 ....      
 egg = new EGG();
 }

  void PBVars::on_but_EditGeometry_clicked()
  {  ...
     // fill Values_from_PBVars here
     egg->show();
     egg->setLneEdits(Values_from_PBVars);
   }

Where and how do I write the connect. 我在哪里以及如何编写连接。 I think it should be somewhat like 我认为应该有点像

  connect(  egg ???, SIGNAL(on_pb_sendValuesToPropBasic_clicked()), 
        this, SLOT(write_GGE_ToPBVars(qsl) ));

where qsl is the Stringlist with the edited values of egg. 其中qsl是带有egg的已编辑值的字符串列表。

can anybody help me please ? 有人可以帮我吗? Thank you !! 谢谢 !!

If you want your connections to transmit data, you have to have matching parameters in the signal and the slot: 如果要使连接传输数据,则必须在信号和插槽中具有匹配的参数:

void someSignal(int)
...
void someSlot(int i) { ...use i here... }

And the actual parameter is specified when you emit the signal emit someSignal(someInt) . 当发出信号时,将指定实际参数,然后emit someSignal(someInt)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM