setWindowFlags(Qt::WindowStaysOnTopHint); //设置窗口置顶 int len = fontMetrics().width( msg );msg为字符串,获取它的物理宽度