You can use SQL to create a virtual layer."Virtual Layer" via Layer/ Add layer/ add-edit virtual layer
:
select row_number() over() as new_id,
a.id as a_id,
b.id as b_id,
setsrid( make_line(a.geometry, b.geometry), st_srid(a.geometry)) as geometry
from myPoints as a
cross join myPoints as b
where a.id < b.id
The query joins the layer to itself where ids are different, then creates a line between the joined points.
You need a unique id column, my is named id
. Replace id
in a.id
and b.id
with the name of your id column. And replace myPoints
with your layer name.