2

I want a resize feature in a QWidget using Qt, like the one shown in the image below.

enter image description here

I have used following tried following ways:

using QSizeGrip, setSizeGripEnabled

cbuchart
  • 10,847
  • 9
  • 53
  • 93
Ankul
  • 53
  • 9
  • I have used setSizeGripEnabled(true) but it only provides the cursor on the point of the corner only. – Ankul Jun 01 '17 at 13:54
  • That property is available only for [`QDialog`](http://doc.qt.io/qt-5/qdialog.html#sizeGripEnabled-prop). – cbuchart Jun 01 '17 at 15:01
  • Please provide me to do this using QDialog also. I have used all the ways that are given on diff portals but it is not working... – Ankul Jun 02 '17 at 04:12
  • "I have used all the ways...", it would be very convenient that in your question you post all the paths you've taken. – cbuchart Jun 02 '17 at 04:40
  • Well, I meant to include a [mcve], to show your actual code (like in the answers), try to reproduce those examples and then start building upon them, maybe there is an option that you've activated without noticing it. Please, review the answers and update your question with actual code, parameters, screenshots... – cbuchart Jun 02 '17 at 07:18

1 Answers1

0

For completeness I'm showing two examples: with and without the Qt Designer.


Example using Qt Designer

designer

Check the sizeGripEnabled property:

properties

Preview from within the Qt Designer (Form > Preview...):

preview

Minimal application to show the dialog:

#include <QtWidgets/QApplication>
#include <QDialog>
#include "ui_DialogButtonBottom.h"

class Dialog : public QDialog {
public:
  Dialog(QWidget* parent = nullptr) :
    QDialog(parent) {
    ui.setupUi(this);
  }

private:
  Ui::Dialog ui;
};

int main(int argc, char* argv[])
{
  QApplication a(argc, argv);

  Dialog dlg;
  return dlg.exec();
}

Resut

result


Without Qt Designer

#include <QtWidgets/QApplication>
#include <QDialog>

class Dialog : public QDialog {
public:
  Dialog(QWidget* parent = nullptr) :
    QDialog(parent) {
    setWindowTitle("Example");
    setSizeGripEnabled(true);
  }
};

int main(int argc, char* argv[])
{
  QApplication a(argc, argv);

  Dialog dlg;
  return dlg.exec();
}

Result

result


Update to include Frameless mode

Adding the Frameless windows hint doesn't change anything: it works correctly. Obviously, there is no frame so resize/move methods provided by the windows manager are not available.

#include <QtWidgets/QApplication>
#include <QDialog>

class Dialog : public QDialog {
public:
  Dialog(QWidget* parent = nullptr, Qt::WindowFlags flags = 0) :
    QDialog(parent, flags) {
    setWindowTitle("Example");
    setSizeGripEnabled(true);
  }
};

int main(int argc, char* argv[])
{
  QApplication a(argc, argv);

  Dialog dlg(nullptr, Qt::FramelessWindowHint); // frameless
  return dlg.exec();
}

Result

frameless


As all the options are working straightforwardly, I'd suggest you to carefully review your code/UI design for things like setting a maximum/minimum size (if both are the same, the grip will still be available but won't change the size at all).

cbuchart
  • 10,847
  • 9
  • 53
  • 93