Keeping guns while keeping your children safe takes a bit of planning, but doesn't require extreme expense or difficulty.
Childhood gun accidents are rare, and there are usually common contributing factors. If you pay attention to the details, you'll see things like drugs, prior police or children's services investigations, a convicted criminal living in the house, an unemployed boyfriend watching children from a previous relationship, subsidized housing or a trailer. (Most of these links fit multiple categories) Child accidents in stable middle class homes are even more uncommon, by a good bit.
Keeping children safe is relatively simple--you never leave a gun unattended even momentarily unless it is locked. Note that I don't specify loaded or unloaded. To do this while retaining a reasonable ability to use the gun for defense is a little harder, but still within reason. In general you trade access time for child-resistance.
The easiest and most effective method that I am aware of for handguns is to use a digital combination lock box or safe to store guns that are not holstered and under the direct control of an adult. You will need an extra 3 to 4 seconds to get the gun out. I have a small Honeywell box from Walmart in the bedroom, mounted to a wall and hidden. I have a larger Stack-On box mounted on high shelf in a closet as the main storage. If I were to start over, I'd get one of the smaller Stack-On boxes instead of the Honeywell. Either will do fine to keep a small child out, the Stack-on will slow a thief down a bit longer. Gun shops sell dedicated quick-access boxes, similar in concept, a bit sturdier, possibly a little faster to access. I'm told you should get the ones with a key backup--no personal experience.
If quick access is not needed, then a locking toolbox or locked closet are other options. Locking gun cabinets capable of holding long guns start around $80. Again, not enough to protect against a determined thief, enough to keep a child from getting hurt, as long as you do not leave keys around. Anything short of a full-sized fire-resistant gun safe should be attached to a wall or the floor.
If a handgun is used for defense, it remains loaded while locked up--There is little advantage to unloading for storage, and several additional risks. Negligent discharges are more likely the more a loaded gun is manipulated, and loading the same round of ammunition many times in a semi-automatic can result in the bullet being shoved too far into the case. When fired, the shoved-in bullet can create extra pressure, enough to burst the barrel and potentially injure the shooter. (Yes, you could just discard that round, but premium ammo is a bit expensive to do that often. It is OK to reload a round a few times--I partially empty the magazine, chamber the next round, then re-load the magazine)
Trigger locks are fine as extra protection for recreational guns, but aren't a good idea on defensive guns. They are slow to unlock, do not prevent theft, and they cannot be safely used on a loaded gun. I don't bother with trigger locks on my guns, since mine are stored in a locked container.
Be regular in your habits. If you carry, put the gun in a safe place as soon as you unholster. I don't have kids in the house, and don't lock my carry gun up when I take it off if I will be home with it--it becomes my "nightstand gun". However, I do put it in the same place every time. When I get dressed, or if guests come, I either put it back on or lock it up.
At some point when they are old enough to be curious children should be allowed to see your guns, unloaded and under close supervision to remove the mystery. Many gun owners have a dividing line--Once a child begins shooting a real gun (or in some cases an airgun) they are no longer allowed to play with toy guns, and must follow the four rules with all guns, even toys.
(Suggestions welcome in comments)