def __init__(self, parent=None):
super(DragWidget, self).__init__(parent)
dictionaryFile = QFile(':/dictionary/words.txt')
dictionaryFile.open(QIODevice.ReadOnly)
x = 5
y = 5
for word in QTextStream(dictionaryFile).readAll().split():
wordLabel = DragLabel(word, self)
wordLabel.move(x, y)
wordLabel.show()
x += wordLabel.width() + 2
if x >= 195:
x = 5
y += wordLabel.height() + 2
newPalette = self.palette()
newPalette.setColor(QPalette.Window, Qt.white)
self.setPalette(newPalette)
self.setAcceptDrops(True)
self.setMinimumSize(400, max(200, y))
self.setWindowTitle("Draggable Text")
评论列表
文章目录