Results 1 to 1 of 1

Thread: insert my own class (a ui from qt designer) into a QtGui.QListWidget

  1. #1
    Join Date
    Mar 2013
    Posts
    1
    Qt products
    Platforms
    Unix/X11 Windows

    Default insert my own class (a ui from qt designer) into a QtGui.QListWidget

    this is what i want to achive i want to put many forms isnside the QListWidget
    https://dl.dropboxusercontent.com/u/...t_designer.png


    this is the code generated from Qt Designer
    # -*- coding: utf-8 -*-
    # Form implementation generated from reading ui file 'lists.ui'
    # Created: Mon Jun 23 16:28:15 2014
    # by: PyQt4 UI code generator 4.9.1
    # WARNING! All changes made in this file will be lost!
    from PyQt4 import QtCore, QtGui
    try:
    _fromUtf8 = QtCore.QString.fromUtf8
    except AttributeError:
    _fromUtf8 = lambda s: s


    LIST class

    class Ui_Dialog_lists(object):
    # class Ui_Dialog_lists(QtGui.QWidget):
    # def __init__(self):
    # QtGui.QWidget.__init__(self)
    # self.setupUi(self)

    def setupUi(self, Dialog_lists):
    Dialog_lists.setObjectName(_fromUtf8("Dialog_lists "))
    Dialog_lists.resize(590, 521)
    self.main_verticalLayout = QtGui.QVBoxLayout(Dialog_lists)
    self.main_verticalLayout.setObjectName(_fromUtf8(" main_verticalLayout"))
    self.horizontalLayout = QtGui.QHBoxLayout()
    self.horizontalLayout.setObjectName(_fromUtf8("hor izontalLayout"))
    self.listWidget_nodes = QtGui.QListWidget(Dialog_lists)
    self.listWidget_nodes.setObjectName(_fromUtf8("lis tWidget_nodes"))
    self.horizontalLayout.addWidget(self.listWidget_no des)
    self.label_arrow = QtGui.QLabel(Dialog_lists)
    self.label_arrow.setObjectName(_fromUtf8("label_ar row"))
    self.horizontalLayout.addWidget(self.label_arrow)
    self.listWidget_nodes_to_render = QtGui.QListWidget(Dialog_lists)
    self.listWidget_nodes_to_render.setObjectName(_fro mUtf8("listWidget_nodes_to_render"))
    self.horizontalLayout.addWidget(self.listWidget_no des_to_render)
    self.main_verticalLayout.addLayout(self.horizontal Layout)
    self.retranslateUi(Dialog_lists)
    QtCore.QMetaObject.connectSlotsByName(Dialog_lists )

    def retranslateUi(self, Dialog_lists):
    Dialog_lists.setWindowTitle(QtGui.QApplication.tra nslate("Dialog_lists", "Dialog", None, QtGui.QApplication.UnicodeUTF8))
    self.label_arrow.setText(QtGui.QApplication.transl ate("Dialog_lists", ">", None, QtGui.QApplication.UnicodeUTF8))




    FORM CLASS
    # -*- coding: utf-8 -*-

    # Form implementation generated from reading ui file 'nodes.ui'
    #
    # Created: Mon Jun 23 16:28:02 2014
    # by: PyQt4 UI code generator 4.9.1
    #
    # WARNING! All changes made in this file will be lost!

    from PyQt4 import QtCore, QtGui

    try:
    _fromUtf8 = QtCore.QString.fromUtf8
    except AttributeError:
    _fromUtf8 = lambda s: s

    class Ui_Frame_hou_node(QtGui.QWidget):
    def __init__(self):
    QtGui.QWidget.__init__(self)
    self.setupUi(self)

    def setupUi(self, Frame_hou_node):
    print "hey"
    Frame_hou_node.setObjectName(_fromUtf8("Frame_hou_ node"))
    Frame_hou_node.resize(329, 60)
    Frame_hou_node.setFrameShape(QtGui.QFrame.StyledPa nel)
    Frame_hou_node.setFrameShadow(QtGui.QFrame.Raised)
    self.main_verticalLayout = QtGui.QVBoxLayout(Frame_hou_node)
    self.main_verticalLayout.setObjectName(_fromUtf8(" main_verticalLayout"))
    self.horizontalLayout_names = QtGui.QHBoxLayout()
    self.horizontalLayout_names.setObjectName(_fromUtf 8("horizontalLayout_names"))
    self.ui_label_node = QtGui.QLabel(Frame_hou_node)
    self.ui_label_node.setObjectName(_fromUtf8("ui_lab el_node"))
    self.horizontalLayout_names.addWidget(self.ui_labe l_node)
    self.ui_label_name_start = QtGui.QLabel(Frame_hou_node)
    self.ui_label_name_start.setObjectName(_fromUtf8(" ui_label_name_start"))
    self.horizontalLayout_names.addWidget(self.ui_labe l_name_start)
    self.ui_label_name_end = QtGui.QLabel(Frame_hou_node)
    self.ui_label_name_end.setObjectName(_fromUtf8("ui _label_name_end"))
    self.horizontalLayout_names.addWidget(self.ui_labe l_name_end)
    self.ui_label_name_inter = QtGui.QLabel(Frame_hou_node)
    self.ui_label_name_inter.setObjectName(_fromUtf8(" ui_label_name_inter"))
    self.horizontalLayout_names.addWidget(self.ui_labe l_name_inter)
    self.main_verticalLayout.addLayout(self.horizontal Layout_names)
    self.horizontalLayout_Inputs = QtGui.QHBoxLayout()
    self.horizontalLayout_Inputs.setObjectName(_fromUt f8("horizontalLayout_Inputs"))
    self.label_node_name = QtGui.QLabel(Frame_hou_node)
    self.label_node_name.setObjectName(_fromUtf8("labe l_node_name"))
    self.horizontalLayout_Inputs.addWidget(self.label_ node_name)
    self.lineEdit_node_start = QtGui.QLineEdit(Frame_hou_node)
    self.lineEdit_node_start.setObjectName(_fromUtf8(" lineEdit_node_start"))
    self.horizontalLayout_Inputs.addWidget(self.lineEd it_node_start)
    self.lineEdit_node_end = QtGui.QLineEdit(Frame_hou_node)
    self.lineEdit_node_end.setObjectName(_fromUtf8("li neEdit_node_end"))
    self.horizontalLayout_Inputs.addWidget(self.lineEd it_node_end)
    self.lineEdit_node_inter = QtGui.QLineEdit(Frame_hou_node)
    self.lineEdit_node_inter.setObjectName(_fromUtf8(" lineEdit_node_inter"))
    self.horizontalLayout_Inputs.addWidget(self.lineEd it_node_inter)
    self.main_verticalLayout.addLayout(self.horizontal Layout_Inputs)

    self.retranslateUi(Frame_hou_node)
    QtCore.QMetaObject.connectSlotsByName(Frame_hou_no de)

    def retranslateUi(self, Frame_hou_node):
    Frame_hou_node.setWindowTitle(QtGui.QApplication.t ranslate("Frame_hou_node", "Frame", None, QtGui.QApplication.UnicodeUTF8))
    self.ui_label_node.setText(QtGui.QApplication.tran slate("Frame_hou_node", "Node", None, QtGui.QApplication.UnicodeUTF8))
    self.ui_label_name_start.setText(QtGui.QApplicatio n.translate("Frame_hou_node", "Start", None, QtGui.QApplication.UnicodeUTF8))
    self.ui_label_name_end.setText(QtGui.QApplication. translate("Frame_hou_node", "End", None, QtGui.QApplication.UnicodeUTF8))
    self.ui_label_name_inter.setText(QtGui.QApplicatio n.translate("Frame_hou_node", "Inter", None, QtGui.QApplication.UnicodeUTF8))
    self.label_node_name.setText(QtGui.QApplication.tr anslate("Frame_hou_node", "Node Name", None, QtGui.QApplication.UnicodeUTF8))


    and i am creating a class that can use them like this.



    from lists import Ui_Dialog_lists
    from nodes import Ui_Frame_hou_node

    from PyQt4 import QtCore, QtGui
    import sys

    icon_test = "/desktop/icons/bomb.rgb"

    class master(QtGui.QWidget, Ui_Dialog_lists):
    def __init__(self):
    print "w"
    QtGui.QWidget.__init__(self)
    self.setupUi(self)
    self.t()

    def t(self):
    print 2
    urr = Ui_Frame_hou_node
    iccon = QtGui.QIcon(icon_test)
    urr.show(self)

    # wi = QtGui.QListWidgetItem()
    # wi.setIcon(iccon)
    # self.listWidget_nodes.addItem(wi)

    # self.listWidget_nodes_to_render.setItemWidget(urr)

    app = QtGui.QApplication(sys.argv)
    m = master()
    m.show()
    app.exec_()



    how can i put my class with all the widgets inside another widget? the class i want to put it inside the qlistwidget, in this case?

    thanks you guys, been a newbee with QT i really apreciate it.
    Attached Images Attached Images

Similar Threads

  1. QListWidget Insert Items
    By wallacesoh in forum Qt Programming
    Replies: 2
    Last Post: 24th February 2014, 07:29
  2. (PyQt4) QtGui QListWidget adding new item problem
    By mshemuni in forum Qt Programming
    Replies: 0
    Last Post: 4th September 2012, 05:05
  3. Replies: 7
    Last Post: 18th August 2011, 15:43
  4. How to insert QProgressbar in a QListWidget?
    By mismael85 in forum Qt Programming
    Replies: 1
    Last Post: 19th September 2010, 07:54
  5. Insert an item in an horizontal QListWidget
    By satoshi in forum Qt Programming
    Replies: 8
    Last Post: 19th May 2009, 18:33

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.