O is the center of square and point P is at height h from the center
OA=OB=OC=OD=a
The magnitude of the electric force due to each charge is 14πε0Qqa2+h2
The components of the the force perpendicular to OP sum up to zero because of the symmetrical distribution of charges about OP. Hence, the resultant force at P is upward along OP. The magnitude of the force is given by
Rup=4×14πε0Qqh2+a2cosθ
=Qqπε0(h2+a2)h√h2+a2=Qqhπε0(h2+a2)3/2
Fdown=weight=mg
For equilibrium, mg=Qqhπε0(h2+a2)3/2
or Q=πε0mghq(h2+a2)3/2