We generalize the quantum heat engine (QHE) model which was first proposed by Bender et al. [J. Phys. A 33, 4427 (2000)] to the case in which an ideal Fermi gas with an arbitrary number N of particles in a box trap is used as the working substance. Besides two quantum adiabatic processes, the engine model contains two isoenergetic processes, during which the particles are coupled to energy baths at a high constant energy E(h) and a low constant energy E(c), respectively. Directly employing the finite-time thermodynamics, we find that the power output is enhanced by increasing particle number N (or decreasing minimum trap size L(A)) for given L(A) (or N), without reduction in the efficiency. By use of global optimization, the efficiency at possible maximum power output (EPMP) is found to be universal and independent of any parameter contained in the engine model. For an engine model with any particle-number N, the efficiency at maximum power output (EMP) can be determined under the condition that it should be closest to the EPMP. Moreover, we extend the heat engine to a more general multilevel engine model with an arbitrary 1D power-law potential. Comparison between our engine model and the Carnot cycle shows that, under the same conditions, the efficiency η = 1 - E(c)/E(h) of the engine cycle is bounded from above the Carnot value η(c) =1 - T(c)/T(h).