Bug report #11517

Size restrictions of custom forms created in Qt Designer not honored

Added by Roi Hojgaard about 5 years ago. Updated about 4 years ago.

Status:Closed
Priority:Normal
Assignee:Alessandro Pasotti
Category:Forms
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:Yes Resolution:fixed/implemented
Crashes QGIS or corrupts data:No Copied to github as #:19787

Description

Dear developers.

No matter which "sizePolicy" settings I choose for the forms I create in Qt Designer, the forms get more or less random size in QGIS (both in 2.4 and nightly dev). Even if "sizePolicy" is "Fixed", the size can still be freely changed in QGIS.

To create custom forms in Qt Designer is an extremely cool feature, IMHO. But with the size settings not honored, the forms will look amateurish, if implemented in our clients GIS environment.

Please fix for 2.6. Thanks.

Our QGIS runs on windows 7 64 bit; PostgreSQL 9.2.5 and PostGIS 2.0.3 are running on CentOS 6.5 Final 64 bit.

Associated revisions

Revision ad2caed3
Added by Alessandro Pasotti about 4 years ago

Removed parent and replaced with QgsAttributeDialog

This makes possible to resize/alter the outer dialog
from python init code in the form.

Fixes #11517 (indirectly)

History

#1 Updated by Jürgen Fischer about 5 years ago

  • Priority changed from High to Normal

#2 Updated by Roi Hojgaard about 5 years ago

This works fine in 2.2 btw.

#3 Updated by Giovanni Manghi about 5 years ago

  • Status changed from Open to Feedback

If this is a regression this should be tagged as blocker, but I'm not sure is a good idea so near the release. Jürgen, your call, thanks.

#4 Updated by Matthias Kuhn about 5 years ago

It was reported quite short before release (actually after the original release date) and is a UX glitch rather than a big issue. -1 for tagging it as a blocker, there are more important issues. I'll take care of it for 2.8 (unless somebody fixes it for 2.6 of course).

Sidenote: In general forms look not too bad if using Qt layouts. And dialog geometries are saved across sessions.

#5 Updated by Jürgen Fischer about 5 years ago

  • Target version changed from Version 2.6 to Future Release - High Priority

#6 Updated by Matthias Kuhn almost 5 years ago

Can you attach an affected form that behaves differently in 2.2 and >=2.4?

#7 Updated by Alessandro Pasotti about 4 years ago

  • Resolution set to worksforme
  • Assignee set to Alessandro Pasotti

I cannot reproduce, setting the dialog size policy to Minimum or MinimumExpanding from designer in the UI file works for me, I didn't test other options but I don't see any reason why they should not work.

Can you please provide an example form that does not work?

#8 Updated by Alessandro Pasotti about 4 years ago

Fixed size it's ignored indeed...

#9 Updated by Alessandro Pasotti about 4 years ago

  • Status changed from Feedback to Closed

I confirm that it's working: to get the desired fixed size, you need to set minimumSize and maximumSize properties in addition to the *sizePolicy.

#10 Updated by Alessandro Pasotti about 4 years ago

  • Resolution deleted (worksforme)
  • Status changed from Closed to Reopened

Re-checked and this is indeed a problem since the form is embedded in a dialog and the parent is not set correctly, hence it's not even reachable via init python code.

Patch is almost ready.

#11 Updated by Alessandro Pasotti about 4 years ago

  • Status changed from Reopened to In Progress
  • Resolution set to fixed/implemented
  • Pull Request or Patch supplied changed from No to Yes

Fixed (indirectly) with https://github.com/qgis/QGIS/pull/2449
that makes possible to alter the outer dialog from python code in the form, the following example set the container to a fixed size of 800x600, the resulting form dialog will not be resizeable.

# -*- coding: utf-8 -*-
""" 
QGIS forms can have a Python function that is called when the form is
opened.

Use this function to add extra logic to your forms.

Enter the name of the function in the "Python Init function" 
field.
An example follows:
""" 

from qgis.core import QgsMessageLog
from PyQt4.QtGui import QSizePolicy

def my_form_open(dialog, layer, feature):
    QgsMessageLog.logMessage(str(dialog))
    dialog.parent().setFixedWidth(800)
    dialog.parent().setFixedHeight(600)
    dialog.parent().setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)

#12 Updated by Alessandro Pasotti about 4 years ago

  • Status changed from In Progress to Closed

Also available in: Atom PDF