Qt textEdit Window size
-
What do you get if you use just this:
class AddSCADWidget(QtGui.QWidget): def __init__(self,*args): QtGui.QWidget.__init__(self,*args) # Main text area self.textEdit=QtGui.QTextEdit() # Message Area self.textMsg=QtGui.QPlainTextEdit() self.textMsg.setReadOnly(True) h = int(2.5 * self.textMsg.fontMetrics().height()) self.textMsg.setMaximumHeight(h) layout= QtGui.QVBoxLayout(self) layout.addWidget(self.textEdit, 2) layout.addWidget(self.textMsg, 1)
-
What do you get if you use just this:
class AddSCADWidget(QtGui.QWidget): def __init__(self,*args): QtGui.QWidget.__init__(self,*args) # Main text area self.textEdit=QtGui.QTextEdit() # Message Area self.textMsg=QtGui.QPlainTextEdit() self.textMsg.setReadOnly(True) h = int(2.5 * self.textMsg.fontMetrics().height()) self.textMsg.setMaximumHeight(h) layout= QtGui.QVBoxLayout(self) layout.addWidget(self.textEdit, 2) layout.addWidget(self.textMsg, 1)
@SGaist 
-
It looks like you only have access to half a widget ?
That's strange, what if you addself.textEdit.setMinimumHeight(4096)
? -
Setting minimumHeight(4096) ( And removing message Window ) still does not expand the the textEdit
-
This is getting stranger and stranger... what if you use setFixedSize ?
-
@SGaist My Bad minimumHeight gave me

So I have to some how get the parent window size and calculate the size? Or is there a better way?
-
You shouldn't need to do that.
How are you integrating your code with FreeCAD ?
-
It is a FreeCAD workbench so it exists in a subdirectory of Mod in the FreeCAD file structure and as FreeCAD finds a InitGui.py and Init.py file it gets invoked. When the user selects the workbench in this case OpenSCAD it gets started, which registers a number of icons. Press on one of these icons invokes code that creates the boxes in one of the FreeCAD windows, the window can vary in size depending on users monitor, whether is has the Combo View panel displayed and can adjust the size of the Combo window.
-
class AddSCADTask: def __init__(self): self.form = AddSCADWidget() class AddSCADWidget(QtGui.QWidget): def __init__(self,*args): QtGui.QWidget.__init__(self,*args) # Main text area self.textEdit=QtGui.QTextEdit() .... etc ... class AddOpenSCADElement: def IsActive(self): return not FreeCADGui.Control.activeDialog() def Activated(self): panel = AddSCADTask() FreeCADGui.Control.showDialog(panel)
-
Okay in AddSCADTask I added a print(dir(self.form) and got
19:54:00 ['DrawChildren', 'DrawWindowBackground', 'IgnoreMask', 'PaintDeviceMetric', 'PdmDepth', 'PdmDevicePixelRatio', 'PdmDevicePixelRatioScaled', 'PdmDpiX', 'PdmDpiY', 'PdmHeight', 'PdmHeightMM', 'PdmNumColors', 'PdmPhysicalDpiX', 'PdmPhysicalDpiY', 'PdmWidth', 'PdmWidthMM', 'RenderFlag', 'RenderFlags', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'acceptDrops', 'accessibleDescription', 'accessibleName', 'actionEvent', 'actions', 'activateWindow', 'addAction', 'addActions', 'adjustSize', 'autoFillBackground', 'backgroundRole', 'backingStore', 'baseSize', 'blockSignals', 'changeEvent', 'childAt', 'childEvent', 'children', 'childrenRect', 'childrenRegion', 'clearFocus', 'clearMask', 'close', 'closeEvent', 'colorCount', 'connect', 'connectNotify', 'contentsMargins', 'contentsRect', 'contextMenuEvent', 'contextMenuPolicy', 'create', 'createWinId', 'createWindowContainer', 'cursor', 'customContextMenuRequested', 'customEvent', 'deleteLater', 'depth', 'destroy', 'destroyed', 'devType', 'devicePixelRatio', 'devicePixelRatioF', 'devicePixelRatioFScale', 'disconnect', 'disconnectNotify', 'dragEnterEvent', 'dragLeaveEvent', 'dragMoveEvent', 'dropEvent', 'dumpObjectInfo', 'dumpObjectTree', 'dynamicPropertyNames', 'effectiveWinId', 'emit', 'ensurePolished', 'enterEvent', 'event', 'eventFilter', 'find', 'findChild', 'findChildren', 'focusInEvent', 'focusNextChild', 'focusNextPrevChild', 'focusOutEvent', 'focusPolicy', 'focusPreviousChild', 'focusProxy', 'focusWidget', 'font', 'fontInfo', 'fontMetrics', 'foregroundRole', 'frameGeometry', 'frameSize', 'geometry', 'getContentsMargins', 'grab', 'grabGesture', 'grabKeyboard', 'grabMouse', 'grabShortcut', 'graphicsEffect', 'graphicsProxyWidget', 'hasFocus', 'hasHeightForWidth', 'hasMouseTracking', 'hasTabletTracking', 'height', 'heightForWidth', 'heightMM', 'hide', 'hideEvent', 'inherits', 'initPainter', 'inputMethodEvent', 'inputMethodHints', 'inputMethodQuery', 'insertAction', 'insertActions', 'installEventFilter', 'internalWinId', 'isActiveWindow', 'isAncestorOf', 'isEnabled', 'isEnabledTo', 'isEnabledToTLW', 'isFullScreen', 'isHidden', 'isLeftToRight', 'isMaximized', 'isMinimized', 'isModal', 'isRightToLeft', 'isSignalConnected', 'isTopLevel', 'isVisible', 'isVisibleTo', 'isWidgetType', 'isWindow', 'isWindowModified', 'isWindowType', 'keyPressEvent', 'keyReleaseEvent', 'keyboardGrabber', 'killTimer', 'layout', 'layoutDirection', 'leaveEvent', 'locale', 'logicalDpiX', 'logicalDpiY', 'lower', 'mapFrom', 'mapFromGlobal', 'mapFromParent', 'mapTo', 'mapToGlobal', 'mapToParent', 'mask', 'maximumHeight', 'maximumSize', 'maximumWidth', 'metaObject', 'metric', 'minimumHeight', 'minimumSize', 'minimumSizeHint', 'minimumWidth', 'mouseDoubleClickEvent', 'mouseGrabber', 'mouseMoveEvent', 'mousePressEvent', 'mouseReleaseEvent', 'move', 'moveEvent', 'moveToThread', 'nativeEvent', 'nativeParentWidget', 'nextInFocusChain', 'normalGeometry', 'objectName', 'objectNameChanged', 'overrideWindowFlags', 'overrideWindowState', 'paintEngine', 'paintEvent', 'painters', 'paintingActive', 'palette', 'parent', 'parentWidget', 'physicalDpiX', 'physicalDpiY', 'pos', 'previousInFocusChain', 'property', 'raise_', 'receivers', 'rect', 'redirected', 'registerUserData', 'releaseKeyboard', 'releaseMouse', 'releaseShortcut', 'removeAction', 'removeEventFilter', 'render', 'repaint', 'resize', 'resizeEvent', 'restoreGeometry', 'retranslateUi', 'saveGeometry', 'scroll', 'sender', 'senderSignalIndex', 'setAcceptDrops', 'setAccessibleDescription', 'setAccessibleName', 'setAttribute', 'setAutoFillBackground', 'setBackgroundRole', 'setBaseSize', 'setContentsMargins', 'setContextMenuPolicy', 'setCursor', 'setDisabled', 'setEnabled', 'setFixedHeight', 'setFixedSize', 'setFixedWidth',... 19:54:00
Does that help at all?
Sorry don't know how to edit this so its not all on one line.
-
Is there a documentation that describes the process to do that task ? I think you might be missing some minor details to get your widget rendered correctly.