在窗口w上面画个黄色的框:在窗口上添加一个label,然后在label上画框
QLabel label(&w); label.setScaledContents(true); QPixmap pix(w.size()); pix.fill(Qt::transparent); QPainter p(&pix); p.setRenderHint(QPainter::Antialiasing); p.setPen(QPen(Qt::yellow,5)); p.drawRect(w.rect().adjusted(20,20,-20,-20)); label.setPixmap(pix);