Why are you setting the index on widget.tabWidget, but getting the index from this->TabIndex?

Try splitting things up into two calls: the first to obtain the current index, the second to set it. Then print out the values at each step to confirm that A) your slots are getting called as you expect, and B) the correct values are being obtained and computed.