Wow, everyone has some pretty nice solutions here!
I have a fairly simple approach which you could adapt to your own creation.
I used aluminum channel called Cantruss here in Canada, or Unistrut in the US. There are probably several other trade names, as well. It also comes in plated steel. It is commonly used in industrial electrical applications, so you could check a local electrical trade distributor. Aluminum is more expensive, but I think the channel used on mine still came out to less than CAD$100.
The rails are anchored to my box using the stake-pocket holes, and big rubber anchor blocks that come with cheap stake-pocket tie downs. It is very solid and has never worked loose. The advantages are that you don't need to drill any holes in your truck, and it is removable. My entire rig unbolts very simply, and the components will fit into a closet for winter storage. The longest piece is about 6'. I live in an apartment, so that's important for me. I could even store the entire platform under the tonneau, if I wanted.
(The orange things are just spacers I made from plastic log-splitting wedges. They are indestructable, and their angle just happened to match what I needed to make the aluminum channels sit level on the sloping top surface of my bed rails. You may not need spacers on your truck.)