【问题标题】:How to implement QSizeGrip in a Qt frameless window?如何在 Qt 无框窗口中实现 QSizeGrip?
【发布时间】:2011-08-21 16:33:17
【问题描述】:

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

代码会是什么样子?

【问题讨论】:

    标签: c++ qt


    【解决方案1】:

    您只需在布局内窗口的一角添加一个 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();
    

    【讨论】:

    • 如果它是一个小部件的孩子呢?当我将它添加到 QHBoxLayout 时,它会将我所有的小部件“推”到左侧,所以我想让它成为一个小部件的子级,它可以位于的“顶部”
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-04
    • 1970-01-01
    相关资源
    最近更新 更多