如何在Qt无框窗口中实现QSizeGrip?

Eag*_*Eye 3 c++ qt

如何使用Qt无框窗口实现QSizeGrip?

代码会是什么样的?

ale*_*sdm 7

您只需在布局内的窗口一角添加一个QSizeGrip,使其保持在该角落.

QDialog *dialog = new QDialog(0, Qt::FramelessWindowHint);
QVBoxLayout *layout = new QVBoxLayout(dialog);

// To remove any space between the borders and the QSizeGrip...      
layout->setContentsMargins(QMargins());         
// and between the other widget and the QSizeGrip
layout->setSpacing(0);
layout->addWidget(new QTextEdit(dialog));

// The QSizeGrip position (here Bottom Right Corner) determines its
// orientation too
layout->addWidget(new QSizeGrip(dialog), 0, Qt::AlignBottom | Qt::AlignRight);

dialog->show();
Run Code Online (Sandbox Code Playgroud)

  • 如果它是小部件的子代怎么办?当我将它添加到 QHBoxLayout 时,它会将我所有的小部件“推”到左边,所以我想让它成为一个小部件的子部件,它可以坐在它的“顶部” (2认同)