Info about some technics in Qt

  • Hi! I want to know:

    1. How to make QSizeGrip placed to the right bottom corner?
    2. How to make the context menu available to the full application?

    Thanks in advance.

  • Inside zip from
    is a sample from a QCommandLinkButton only swap to normal button ...

      _EpubStart = new StartMenuButton();


    Limit QMenu in one time to display is 30 pieces...

  • @patrik08

    Hi! Thanks, but I don't have QStatusBar to display QSizeGrip.

    I have added QSizeGrip to QGridLayout:

    QSizeGrip *sizeGrip = new QSizeGrip(this);
    QGridLayout *sizeGripLayout = new QGridLayout();
    sizeGripLayout->addWidget(sizeGrip, 0, 0, 1, 1, Qt::AlignBottom | Qt::AlignRight);

    and add QGridLayout to QVBoxLayout (main layout).


    But it adds to much space at the bottom.

  • Or any QWidget have
    to place menu..

    QDialog *dialog = new QDialog(0, Qt::FramelessWindowHint);
    QVBoxLayout *layout = new QVBoxLayout(dialog);
    // To remove any space between the borders and the QSizeGrip...      
    // and between the other widget and the QSizeGrip
    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);

  • @patrik08

    Ok. I have changed code to:

    QVBoxLayout *sizeGripLayout = new QVBoxLayout();
    sizeGripLayout->addWidget(new QSizeGrip(mainWindow), 0, Qt::AlignBottom | Qt::AlignRight); //mainWindow - QWidget

    But the same extra space exists at the bottom:

    Also, I have context menu in contextMenuEvent for example in A how to extend it to B? Setting this->setContextMenuPolicy(Qt::CustomContextMenu); at B will not display the context menu from A. Do I need to create the global class to manage context menu everywhere?

  • In QHBoxLayout I have set setContentsMargins(10, 10, 10, 0); - bottom to 0, so:


    I think, it's better, but one problem, when application is maximized, there is no space at the bottom. Should I change setContentsMargins at event or there is other solution?

  • Debug your item for margin and cast element so:

         QObjectList mx = this->children();
          QList<QObject*>::const_iterator x;
          for (x = mx.constBegin(); x != mx.constEnd(); ++x) {
            QObject *fox = *x;
               qDebug() << "name:" << fox->objectName();
               QWidget *vox = qobject_cast<QWidget *>(fox);
               if (vox) {
                  qDebug() << "size element:" << vox->size() << ":" << vox->accessibleName();

  • @patrik08

    Thanks, but I have changed Qt event and the problem with QSizeGrip has been fixed. The only think now is to create global menu.

  • Lifetime Qt Champion


    Do you mean QMainWindow's menuBar ?

  • I have fixed all issues. Thank you.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.