make a signal valueChanged in classM then connect that signal with QProgressBar::setValue of classS.