资源简介

QT实现的聊天界面,好友列表,支持文字和动态图像收发,python写的,C语言也可以参考

资源截图

代码片段和文件信息

#!/usr/bin/env python

from PyQt4 import QtCore QtGui


class Window(QtGui.QWidget):
    def __init__(self):
        super(Window self).__init__()

        flowLayout = FlowLayout()
        flowLayout.addWidget(QtGui.QPushButton(“Short“))
        flowLayout.addWidget(QtGui.QPushButton(“Longer“))
        flowLayout.addWidget(QtGui.QPushButton(“Different text“))
        flowLayout.addWidget(QtGui.QPushButton(“More text“))
        flowLayout.addWidget(QtGui.QPushButton(“Even longer button text“))
        self.setLayout(flowLayout)

        self.setWindowtitle(“Flow Layout“)


class FlowLayout(QtGui.QLayout):
    def __init__(self parent=None margin=0 spacing=-1):
        super(FlowLayout self).__init__(parent)

        if parent is not None:
            self.setMargin(margin)

        self.setSpacing(spacing)

        self.itemList = []

    def __del__(self):
        item = self.takeAt(0)
        while item:
            item = self.takeAt(0)

    def addItem(self item):
        self.itemList.append(item)

    def count(self):
        return len(self.itemList)

    def itemAt(self index):
        if index >= 0 and index < len(self.itemList):
            return self.itemList[index]

        return None

    def takeAt(self index):
        if index >= 0 and index < len(self.itemList):
            return self.itemList.pop(index)

        return None

    def expandingDirections(self):
        return QtCore.Qt.Orientations(QtCore.Qt.Orientation(0))

    def hasHeightForWidth(self):
        return True

    def heightForWidth(self width):
        height = self.doLayout(QtCore.QRect(0 0 width 0) True)
        return height

    def setGeometry(self rect):
        super(FlowLayout self).setGeometry(rect)
        self.doLayout(rect False)

    def sizeHint(self):
        return self.minimumSize()

    def minimumSize(self):
        size = QtCore.QSize()

        for item in self.itemList:
            size = size.expandedTo(item.minimumSize())

        size += QtCore.QSize(2 * self.margin() 2 * self.margin())
        return size

    def doLayout(self rect testOnly):
        x = rect.x()
        y = rect.y()
        lineHeight = 0

        for item in self.itemList:
            wid = item.widget()
            spaceX = self.spacing() + wid.style().layoutSpacing(QtGui.QSizePolicy.PushButton QtGui.QSizePolicy.PushButton QtCore.Qt.Horizontal)
            spaceY = self.spacing() + wid.style().layoutSpacing(QtGui.QSizePolicy.PushButton QtGui.QSizePolicy.PushButton QtCore.Qt.Vertical)
            nextX = x + item.sizeHint().width() + spaceX
            if nextX - spaceX > rect.right() and lineHeight > 0:
                x = rect.x()
                y = y + lineHeight + spaceY
                nextX = x + item.sizeHint().width() + spaceX
                lineHeight = 0

            if not testOnly:
                item.setGeometry(QtCore.QRect(QtCore.QPoint(x y) item.sizeHint()))

            x = nextX
            lineHeight = max(lineHeight

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-12-15 08:45  pyqtChat-master\
     文件         378  2016-12-15 08:45  pyqtChat-master\.gitattributes
     文件         671  2016-12-15 08:45  pyqtChat-master\.gitignore
     文件        3222  2016-12-15 08:45  pyqtChat-master\flowlayout.py
     文件       21422  2016-12-15 08:45  pyqtChat-master\groupUserList.py
     文件       12354  2016-12-15 08:45  pyqtChat-master\groupUserList_readme.md
     目录           0  2016-12-15 08:45  pyqtChat-master\icons\
     文件       17549  2016-12-15 08:45  pyqtChat-master\icons\arrow_d.png
     文件       16697  2016-12-15 08:45  pyqtChat-master\icons\arrow_r.png
     文件        5441  2016-12-15 08:45  pyqtChat-master\icons\chat.png
     文件       18241  2016-12-15 08:45  pyqtChat-master\icons\copy.png
     文件        4422  2016-12-15 08:45  pyqtChat-master\icons\delete.png
     文件        3053  2016-12-15 08:45  pyqtChat-master\icons\edit.png
     文件        4025  2016-12-15 08:45  pyqtChat-master\icons\group.png
     文件        8220  2016-12-15 08:45  pyqtChat-master\icons\hd_1.png
     文件        3669  2016-12-15 08:45  pyqtChat-master\icons\img.png
     文件       92398  2016-12-15 08:45  pyqtChat-master\icons\qq.png
     文件        3707  2016-12-15 08:45  pyqtChat-master\icons\user.png
     文件       17738  2016-12-15 08:45  pyqtChat-master\msgList.py
     文件        4428  2016-12-15 08:45  pyqtChat-master\msgList_readme.md
     文件        6168  2016-12-15 08:45  pyqtChat-master\pyqtChatApp.py
     文件        2223  2016-12-15 08:45  pyqtChat-master\pyqtChatApp_readme.md
     文件         539  2016-12-15 08:45  pyqtChat-master\readme.md
     目录           0  2016-12-15 08:45  pyqtChat-master\ref\
     文件      247620  2016-12-15 08:45  pyqtChat-master\ref\QListWidget Class Reference.pdf
     文件      219193  2016-12-15 08:45  pyqtChat-master\ref\QListWidgetItem Class Reference.pdf
     文件      304804  2016-12-15 08:45  pyqtChat-master\ref\QTextEdit Class Reference.pdf
     文件        2530  2016-12-15 08:45  pyqtChat-master\ref\bq.gif
     文件      434207  2016-12-15 08:45  pyqtChat-master\ref\mt.gif
     文件       32802  2016-12-15 08:45  pyqtChat-master\ref\pic1.png
     文件       30818  2016-12-15 08:45  pyqtChat-master\ref\pic2.png
............此处省略2个文件信息

评论

共有 条评论