English 中文(简体)
是否在同一物体上的2个位置上使用同一信号?
原标题:Qt use-case for same signal to 2 slots on same object?
  • 时间:2010-01-08 14:56:29
  •  标签:
  • c++
  • qt

我完全是Qt的新手,因为我读了文件。 我参加了这一组合:

connect( Object1, Signal1, Object2, slot1 )
connect( Object1, Signal1, Object2, slot2 )

这可能是这方面的使用情况?

看看我从Erlang/Python的背景。 它必须同C++遗产继承者打交道,并转而我猜测。

最佳回答

情况是,如果你拥有像一个州这样的东西,就会改变另一个州的两个部分。 它可以保持沉默,但相当于将第二个排位职能从第一个位置上调。

Say,点击游戏/乐团,使停靠的纽顿活跃或活跃,并改变工具图。 这很容易用一个位置进行,但你可能希望选择在其他时间独立这样做。 为了促进再利用,你使用上述方法将一个信号连接到两个位置。

问题回答

这将使其他物体能够分别触发排位1和排位2。

connect( Object1, Signal1, Object2, slot1 );
connect( Object1, Signal1, Object2, slot2 );
connect( Object3, Signal1, Object2, slot1 );
connect( Object4, Signal1, Object2, slot2 );

它实际上是一种真正强大的手段,可以做MVC......。 让我说,你想“联系”倾听物体的意见,而不是提供数据......

你可以把PieChart的观点与:

connect( MySourceModel, SIGNAL(newDataAreThere()), PieChartView, SLOT(notifyNewDataReceived()));

在你的申请中,还创建了另一个单元,需要倾听数据...... 无问题:

connect( MySourceModel, SIGNAL(newDataAreThere()), AnotherView, SLOT(notifyNewDataReceived()));

你们可以把你们的意见联系起来/脱节,而这个模式甚至知道谁听了他。 这并不是他的问题。

我希望我很少的例子可以理解;





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签