Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I fully disable resizing a window including the resize icon when the mouse hovers the border?

I used: setFixedSize(size()); to stop the window from resizing, but the resize arrows still appear when the mouse is over the border of the window.

Is there a better way to disable window resizing to avoid showing the arrows when crossing the border?

like image 688
Klasik Avatar asked May 21 '13 14:05

Klasik


People also ask

How do I stop Windows 10 from resizing screen?

Step 1: Navigate to Settings app > System > Multitasking. Step 2: Here, turn off the Snap windows option to stop Windows 10 from automatically resizing windows.

How do I permanently resize a window?

Below are the steps for resizing a window only using the keyboard. Press Alt + Spacebar to open the window's menu. If the window is maximized, arrow down to Restore and press Enter . Press Alt + Spacebar again to open the window menu, arrow down to Size, and press Enter .


Video Answer


3 Answers

Qt has a windowFlag called Qt::MSWindowsFixedSizeDialogHint for that. Depending on what you exactly want, you want to combine this flag with Qt::Widget, Qt::Window or Qt::Dialog.

void MyDialog::MyDialog()
{
  setWindowFlags(Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);

  ...
}
like image 93
Daniël Sonck Avatar answered Oct 19 '22 06:10

Daniël Sonck


One-liner if you know exactly the required size of the window:

this->setFixedSize(QSize(750, 400));
like image 33
Neurotransmitter Avatar answered Oct 19 '22 07:10

Neurotransmitter


Try something like this:

this->statusBar()->setSizeGripEnabled(false);

If this doesn't work, all you need to do is detect what widget is activating QSizeGrip. You can do this by installing an event filter on your app and try to catch the QSizeGrip's mouseMoveEvent. Then debug its parent widget.

Here's an example of the eventFilter function you could use:

bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
    if(event->type() == QEvent::MouseMove)
    {
        QSizeGrip *sg = qobject_cast<QSizeGrip*>(obj);
        if(sg)
            qDebug() << sg->parentWidget();
    }
    return false;
}

You could probably catch its show event as well, it's up to you.

like image 19
thuga Avatar answered Oct 19 '22 07:10

thuga