The throughput performance of the Distributed Coordination Function (DCF) of the IEEE 802.11 MAC protocol quickly degrades as the number of contending stations increases. To solve this problem, it has been shown recently that adaptive contention window modulation based on channel idle time tracking can be used, generating near optimal throughput. In this paper, we extend the approach for the IEEE 802.11e network, where different QoS classes are defined. We show how to find the class-specific optimal contention window sizes that yield the maximum aggregate throughput while maintaining the target throughput difference between classes.