Take a look at how wood is used to make load-bearing spans in any construction. For static loads, the idea is to transfer the loads to the floor, and thence to the ground, with minimal deflection (under normal loads) and without danger of sudden catastrophic failure.
There are three main ways of achieving this:
- Use dimensions large enough to resist deflection and failure; either have large enough pieces, or "sister" them up to make larger pieces.
- Orient the wood so the forces act on it where it is most able to handle those forces. For example, the centre rail of a bed or a house joist is usually placed so that the forces act on the edge of a longer piece, not the face. Because of the internal structure of wood, orienting dimension lumber so the forces are along the smaller width, perpendicular to the larger width, gives you the most durability and strength.
- If you cannot orient your material so the forces are along the strongest face in this manner you have to support those spans with another construction member that can be oriented in this manner.
In the case discussed here, we have to make some decision about the dimensions and orientation of bed slats so that we don't deflect so much that they fall out the bottom, or catastrophically fail during some high activity.
Now, there are all sorts of published data about the relative strengths and maximum loads of dimension lumber of various species. But wood is a natural product, and resists easy categorization like this. In practice, a woodworker will use their experience and the experience of others, along with "feel" to just get an idea of what will work.
For example, take any candidate pine or spruce slat you intend on using; any softwood will do, actually. Place it on two 2x4s so it spans 30 inches or so. Try to deflect it in the centre. You'll find that is is actually quite elastic, and will deflect a lot. If you push hard enough it might even slip off the 2x4, or the forces will push the 2x4s out of the way (which simulates the problem with bed rails bowing out). Try to get a feel for how much force and bounce the material has, and think about how that will work out in the real, dynamic world.
If you think about the static loads of a sleeping child, or the dynamic loads of an active child, you can see that most spans that rely on the strength of the face of softwood usually needs help. That's #3, above.
That being said, wood is incredibly strong for its mass, if used appropriately. Your standard sized 1x4 inch pine slat will be all kinds of strong enough. I think 30 inches is an acceptable span in a queen sized bed for adults using this dimension. It might be too bouncy for a toddler, though. I recommend you give it a test as above and make your own decision. I will point out there is really no penalty here for overbuilding a little.
With smaller dimension slats, you will definitely want to provide a centre rail, which will support the slat by transferring the load along the edge of another member so the load is shared among those members, reducing deflection in each.
Finally, the problem with slats is that they are generally loose. They aren't typically fastened to the side rails because they will just move with humidity and split. For the same reason you can't jam them in tight side-by-side or they will buckle with the next swing in humidity. You can provide pins you let them "float" between, or do the Ikea thing of attaching them with stapled fabric to make a "slat ladder", or even slot them and fasten them loosely so they can move, in the same manner as a solid wood table top is attached to the apron.
But my recommendation is get some sturdy high-quality plywood (i.e., "veneered plywood", similar to the veneers used by flat-pack furniture sellers) and cut that to fit your bed rails, supported on all sides (and possibly a centre-rail, even if to keep the bed from becoming a "drum"). Cut it in half, chamfer the edges, and drill and chamfer a finger hole in each so you can grab them for removal and installation.
A toddler will definitely find the slats, and will definitely want to mess with them. There is the danger they might get their fingers or other body parts jammed in there, with all the potential harm that implies. Using plywood reduces this sort of problem, and is also way more dimensionally stable and stronger than pine slats.