0

[Ques_code][1]

I need to move text from Text Browser playerDataBox to teamDataBox when the button is clicked. How do I do that? I've tried the following:

def addToTeamPushButtonclicked(self):
    print("HAHA you clicked")
    self.teamDataBox.setFontPointSize(16)
    self.teamDataBox.setAlignment(QtCore.Qt.AlignCenter)
    self.teamDataBox.setTextColor(QtGui.QColor("blue"))
    #self.teamDataBox.setSource(QString text = self.playerDataBox.toPlainText())

def batRadioClick(self):
    self.playerDataBox.clear()
    print("You selected BAT radio button")
    batFetchQry = 'select Player from stats where ctg = "BAT";'
    gameDB = sqlite3.connect('FantasyCricket.db')
    gameCursor = gameDB.cursor()
    gameCursor.execute(batFetchQry)
    result = gameCursor.fetchall()
    for record in result:
        self.playerDataBox.setFontPointSize(16)
        self.playerDataBox.setAlignment(QtCore.Qt.AlignCenter)
        self.playerDataBox.setTextColor(QtGui.QColor("blue"))
        self.playerDataBox.append("".join(record))
        self.playerDataBox.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)
        #self.playerDataBox.
        #self.playerDataBox.mousePressEvent(QMouseEvent.QEvent::MouseButtonPress)
    gameDB.close()
Atul Gupta
  • 11
  • 5
  • You want to copy the contents of a QTextBrowser to another? Can't you just use `self.teamDataBox.setHtml(self.playerDataBox.html)`? – musicamante Aug 18 '20 at 08:10
  • I'm new to this tbh...isn't html for webpages? I'll try this. – Atul Gupta Aug 20 '20 at 05:41
  • Html is for rich text contents. I missed a `()` at the end of `playerDataBox.html`, since it's a function call. You are using QTextBrowser, so I assumed you needed rich text. You can also use the [`plainText`](https://doc.qt.io/qt-5/qtextedit.html#plainText-prop) property: `self.teamDataBox.setPlainText(self.playerDataBox.plainText())`. Anywat, you shouldn't probably use QTextBrowser, but its inherited class QTextEdit, and if you don't need rich text, just use [QPlainTextEdit](https://doc.qt.io/qt-5/qplaintextedit.html) – musicamante Aug 20 '20 at 06:44

0 Answers0