To use the principle of virtual work, apply the procedure that Jabba outlined. Let’s apply it to your linked-to diagram.
First step is to imagine the linkage moving just a tiny little bit. “Tiny” means “such a small distance that all the relative angles don’t change.” Now, the question is just exactly which direction does everything move? It’s really just geometry, but it takes some thinking through. Let’s step through the linkage:
Point A doesn’t move at all (of course).
Point B rotates around point A. You can express this by saying that if point B moves a distance dx to the right, it moves a distance cos(60)dx downwards.
Point C moves only horizontally; by symmetry it will move a distance 2dx to the right.
Point D is a little harder to figure out: go through the geometry by imagining the entire beam BCD translating the same distance that B does, and then rotating about B whatever distance it takes to return C to the same horizontal line. When you go through that exercise, if I did the math right, you’ll find that point C moves a distance 3dx to the right and a distance cos(60)dx upwards.
Note that the value of dx is arbitrary, so you might have different numbers for the motion, but the relative motion of all the joints ought to be the same.
OK, now that you know the geometry, apply the principle of virtual work. In a nutshell, this says: the sum of all forces multiplied by the virtual distance they move, in the direction of the force, is zero. Let’s look at each point:
Point A: Has some applied forces, but it doesn’t move. Virtual work = 0
Point B: Moves, but all the forces are internal, so they cancel each other out. Virtual work = 0.
Point C: Has a vertical force, and moves a distance 2dx horizontally. No motion in the direction of the force. Virtual work = 0.
Point D: Moves 3dx in the direction of force P, and cos(60)dx opposite force Q. Virtual work = P*3dx - Qcos(60)dx.
Add 'em up, and find that = P*3dx - Qcos(60)dx = 0. You can do the final math. Note that dx drops out.
You can also solve this problem by summing forces and moments, and indeed I get the same answer (good sign!), but it’s a little more involved.