N
N
nikallassan2019-12-09 04:29:15
JavaScript
nikallassan, 2019-12-09 04:29:15

How to pass text on button click in python qt?

Hello everyone, please tell me how to transfer the text from the line edit when you click on the button to the text browser? I kind of did it, but for some reason it doesn't work, I'm new to programming. please tell me what is wrong and how to fix it.

from PySide2 import QtCore, QtGui, QtWidgets
import sys
from ui import Ui_MainWindow


if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())


def save():
  ui.textBrowser.setText(int(ui.LineEdit))

ui.pushButton.clicked.connect(save)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
0
0xD34F, 2019-01-09
@daima

function mergeIntervals(intervals) {
  intervals = intervals.map(n => [...n]);

  if (intervals.length < 2) {
    return intervals;
  }

  intervals.sort((a, b) => a[0] - b[0]);

  const stack = [ intervals.shift() ];

  intervals.forEach(n => {
    const top = stack[stack.length - 1];

    if (top[1] < n[0]) {
      stack.push(n);
    } else if (top[1] < n[1]) {
      top[1] = n[1];
    }
  });

  return stack;
}

UPD. Taken from the comments:
This is a copy of the array passed to the function so as not to spoil the original - since sorting is performed, the zero element is removed, and the upper bounds of the intervals are changed.

T
TriKrista, 2019-12-09
@TriKrista

maybe so?
ui.textBrowser.setText(int(ui.LineEdit.text()))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question