Upvote:5
The OP doesn't say who they're travelling with or where they're going, so some speculation is in order.
There are only two LHR flights from GIB; the BA493 arriving at T3 at 14:00 and the BA451 arriving at 18:55 so it's safe to assume it is that one. For confirmation there is the EK003 A380 arriving 15 minutes earlier from Dubai at 18:40.
There are a limited number of flights departing from T4 around 10pm and all seem to be departing to the middle east or far east and no domestic flights. The connection process for any of these will be similar, so choosing one at random we can plug in BA491 GIB-LHR connecting to QR016 LHR-DOH into the Heathrow flight connections planner:
As pointed out in comments, providing this is all on one connection, there is no immigration check at T3 and only security screening at T4 for which you have fast track access. The airport guide suggests the time needed for this is 90 minutes and 3 hours is very comfortable even given a delayed arrival from Gibraltar.
If you're not on one ticket and you do need to collect your luggage, the airport gives statistics here, for example June 2016 stats say that 91.25% of non-EEU passengers take less than 45 minutes and 99.21% of EU passengers pass through in under 25 minutes, but those are statistics for the whole month and they don't count the time from landing to reaching the immigration queue. The only answer you can really get is one of probability. With a non-EEU passport, you're likely to pass through immigration between 30 minutes and 2 hours. Even that should give you enough time to get to T4 on a separate ticket if no futher delays.