While in general this would be better handled in PostGIS, there are plug-ins which do the heavy lifting for you:
MMQGis Hub Distance.
This is the preferable and correct way, however could be slow on large datasets.
It has the non trivial advantage to compute the correct polygon-to-line distance, without converting buildings into points ...
Using NUTS-3 centroids with the Near (Analysis) tool, the geodetic distance between the Shetland Islands and Jersey was calculated to be 1191878.03 meters.
Using a Euclidean distance after projecting to British National Grid (with the default datum transformation), those two points are 1191362.07 meters apart (a delta of 515.96 meters, or 0.043 percent).
It looks like a bug and/or improper projection.
Using distances in long-lat degrees (which doesn't mean much), the result is the proper one. Using true ground distances (in meters), the reported distances are the proper ones.
with src as (select 1 as id, st_makepoint(-2.92391,43.25722) as geom),
dest (id, geom) as (values (2, st_makePoint(-3.36708, 40....
Tested on QGIS 2.18 and QGIS 3.4
I can suggest using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer...
Let's assume we have 10 features in "buildings" and 16 in "roads" accordingly, see image below.
With the following Query, it is possible to find out the distance between a given building e.g. WHERE b.propertyid = '1' and the ...
This method expect point in latitude/longitude.
Your coordinates are projected, so you can just do
point1 = QgsPoint(474828.85, 6756169.31)
point2 = QgsPoint(874895.75, 6756159.5)
distance = point1.distance(point2)
If you have the Spatial Analyst extension, you could use the Flow Length tool to create a flow length raster.
Then calculate the difference between the flow lengths of each pair of points based on which cell of the flow length raster they coincide with. (Of course you would need to be sure that both points in the pair are on the same stream).