[PyQt] Layout addWidget alignment

Esteban Martinena Guerrero orensbruli at gmail.com
Wed Jul 1 17:40:13 BST 2015


Hi,

The addWidget method of the Layouts accepts 3 arguments. If you set the
alignment for any widget in a layout tf would be the third argument of the
addWidgetMethod but it's in the second one. This doen't generate any errors
because the second and third parameters are both optional and integers.

Can anyone tell me if you have the same problem?

Best regards.
-- 
Esteban Martinena Guerrero
FotografĂ­a de autor y de prensa
Colaborador Agencia EFE
*Facebook*: http://www.facebook.com/EMartinenaPhoto
*Website*: http://emartinena.es
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150701/5b706b06/attachment-0001.html>
-------------- next part --------------
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'test.ui'
#
# Created: Wed Jul 01 18:33:49 2015
#      by: PyQt4 UI code generator 4.11.3
#
# WARNING! All changes made in this file will be lost!

from PyQt4 import QtCore, QtGui

try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    def _fromUtf8(s):
        return s

try:
    _encoding = QtGui.QApplication.UnicodeUTF8
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig)

class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName(_fromUtf8("Form"))
        Form.resize(181, 92)
        self.verticalLayout = QtGui.QVBoxLayout(Form)
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.label = QtGui.QLabel(Form)
        self.label.setObjectName(_fromUtf8("label"))
        self.verticalLayout.addWidget(self.label, QtCore.Qt.AlignRight)
        self.line = QtGui.QFrame(Form)
        self.line.setFrameShape(QtGui.QFrame.VLine)
        self.line.setFrameShadow(QtGui.QFrame.Sunken)
        self.line.setObjectName(_fromUtf8("line"))
        self.verticalLayout.addWidget(self.line, QtCore.Qt.AlignRight)

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        Form.setWindowTitle(_translate("Form", "Form", None))
        self.label.setText(_translate("Form", "TextLabel", None))

-------------- next part --------------
A non-text attachment was scrubbed...
Name: qtDoc.jpg
Type: image/jpeg
Size: 24207 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150701/5b706b06/attachment-0003.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: WidgetInspector.jpg
Type: image/jpeg
Size: 16412 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150701/5b706b06/attachment-0004.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pyqt_problem.jpg
Type: image/jpeg
Size: 62626 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150701/5b706b06/attachment-0005.jpg>
-------------- next part --------------
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>Form</class>
 <widget class="QWidget" name="Form">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>181</width>
    <height>92</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>Form</string>
  </property>
  <layout class="QVBoxLayout" name="verticalLayout">
   <item alignment="Qt::AlignRight">
    <widget class="QLabel" name="label">
     <property name="text">
      <string>TextLabel</string>
     </property>
    </widget>
   </item>
   <item alignment="Qt::AlignRight">
    <widget class="Line" name="line">
     <property name="orientation">
      <enum>Qt::Vertical</enum>
     </property>
    </widget>
   </item>
  </layout>
 </widget>
 <resources/>
 <connections/>
</ui>


More information about the PyQt mailing list