Info about some technics in Qt
-
Hi! I want to know:
- How to make
QSizeGrip
placed to the right bottom corner? - How to make the context menu available to the full application?
Thanks in advance.
- How to make
-
Inside zip from https://github.com/pehohlva/Tiny_Edit/tree/master/tests
is a sample from a QCommandLinkButton only swap to normal button ..._EpubStart = new StartMenuButton(); _EpubStart->setMenu(menuTocEpub); statusBar()->addWidget(_EpubStart); statusBar()->setSizeGripEnabled(false);
Limit QMenu in one time to display is 30 pieces...
-
Hi! Thanks, but I don't have
QStatusBar
to displayQSizeGrip
.I have added
QSizeGrip
toQGridLayout
:QSizeGrip *sizeGrip = new QSizeGrip(this); QGridLayout *sizeGripLayout = new QGridLayout(); sizeGripLayout->setContentsMargins(QMargins()); sizeGripLayout->setSpacing(0); sizeGripLayout->addWidget(sizeGrip, 0, 0, 1, 1, Qt::AlignBottom | Qt::AlignRight);
and add
QGridLayout
toQVBoxLayout
(main layout).But it adds to much space at the bottom.
-
Or any QWidget have
http://doc.qt.io/qt-4.8/qwidget.html#contextMenuPolicy-prop
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... 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();
-
Ok. I have changed code to:
QVBoxLayout *sizeGripLayout = new QVBoxLayout(); sizeGripLayout->setContentsMargins(QMargins()); sizeGripLayout->setSpacing(0); 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? Settingthis->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 setsetContentsMargins(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
atevent
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(); } }
-
Hi,
Do you mean QMainWindow's menuBar ?
-
I have fixed all issues. Thank you.