In a quantum Stirling heat engine, the heat exchanged with two thermal baths is partly utilized for performing work by redistributing the energy levels of the working substance. We analyze the thermodynamics of a quantum Stirling engine operating in finite time. We develop a model in which a time-dependent potential barrier changes the energy-level structure of the working substance. The process takes place under a constant interaction with the thermal bath. We further show that in the limit of slow operation of the cycle and low temperature, the efficiency of such an engine approaches Carnot efficiency. We also show that the maximum output power, for the strokes that affect the energy levels, is obtained at an intermediate operating speed, demonstrating the importance of a finite-time analysis.