I'm not sure if this is even possible in QGIS, but I try to filter features in a layer based on the names of visible layers within a certain group.
Example: I have a group holding layers named by different countries. In another layer, e.g. called stations, I have an attribute called "country" which I want to filter by the names of countries which are toggled on (visible) in the group. So if I display the layers Germany and Italy in the group, the stations layer will be filtered automatically by Germany and Italy.