Wireless Sensor Networks are composed of autonomous interconnected sensing devices. Power limitation is considered as the most significant constraint for sensors. It directly influences the sensors ' lifetime and hence the application quality of service. Many studies have been conducted in the field, where different power-based routing and data gathering strategies are proposed. However, most of them are driven for specific applications and for specific network topologies. In this paper, we propose a power-and-QoS-based framework for heterogeneous sensor networks. This framework is formulated as an optimization problem. It aims at maximizing the application lifetime while ensuring acceptable level of quality of service. Moreover, the proposed framework is designed for a general network architecture where both clustered and hierarchical structures can coexist. The framework simultaneously optimizes intra-cluster transmissions and inter-cluster multi-hop routing.