class WidgetStacked : public QStackedWidget{ //... explicit WidgetStacked (QWidget * parent) : QStackedWidget(parent) { //... pthread_t th; pthread_create(&th, 0, ThreadCallback, (void *)this); } friend void * ThreadCallback(void * param);};void * ThreadCallback(void * param){ //... ((WidgetStacked *)param)->setCurrentIndex(0);}