I had always assumed that the encounter with the Borg in "Q Who" had alerted the Borg to the Federation presence and that it was because of this encounter that they sent the cube that attacked Earth in "The Best of Both Worlds". But recently I realised that maybe the Borg were already on their way and Q was not in fact unleashing a giant threat upon the Federation just to spite Picard, but rather allowed them a glimpse into the future so they could prepare for an attack that was already underway at that time.
Now ovbiously the events in First Contact and ENT indicate that the Borg were aware of the Federation's presence by the time of "Q Who" (see e.g. this question), but I am more interested in a purely TNG interpretation of the issue, essentially only including things that had aired up to (and including) TBoBW/Family:
Did the events in "Q Who" trigger the Borg attack on Federation space, or did they merely serve to warn Picard of an attack that was already underway?