5

I am creating a form using PYQT

self.texteditor1= QtGui.QLineEdit(self) 
self.texteditor1.setFixedWidth(560)

I wanted to know that how to increase font size of texteditor in above case ?

3 Answers 3

3

Try with:

f = self.texteditor1.font()
f.setPointSize(27) # sets the size to 27
self.texteditor1.setFont(f)
Sign up to request clarification or add additional context in comments.

Comments

3

Set pointSize property of lineedit font.

self.texteditor1 = QtGui.QLineEdit(self)
font = self.texteditor1.font()      # lineedit current font
font.setPointSize(32)               # change it's size
self.texteditor1.setFont(font)      # set font

2 Comments

Thanks. Can you please tell that how to wrap text in the QLineEdit box ?
That won't happen on line. You will have to use different widget. Read some docs and if you find a problem, ask a new question.
0

Short answer:

self.input_field = QLineEdit()
self.input_field.setFont(QFont('Arial', 15))  # this is what you need!

Full answer:

# import libraries you need!
import sys
from PyQt5.QtWidgets import QMainWindow, QApplication, QWidget, QLineEdit
from PyQt5.QtGui import QFont


class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()

        # some code

        self.input_field = QLineEdit()
        self.input_field.setFont(QFont('Arial', 15))  # this is what you need!

        # some code

        container = QWidget()
        self.setCentralWidget(container)


app = QApplication(sys.argv)

window = MainWindow()
window.show()

app.exec()

1 Comment

This is not a good answer, because it may reset the family, weight and bold properties of the existing font as well as its point-size. The other answers show a more robust way to change the point-size.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.