Unsolved Set QLineEdit width in 1 symbol
-
Hello, how can I set starting width for QLineEdit instance in 1 character? Instance will be placed at QGridLayout. QLineEdit's default width is too big for using table 9x9 QLineEdits. (No way for using models because their usage is a bit complicated for a very simple app).
-
Did you try setFixedSize(5,5) ?
-
@Northsoft
If you mean get it be exactly 1 character wide, you'd have to call to measure the width of a character in the font (and think about if it's a proportional font) which it is going to use. Is that what you have in mind? -
@dheerendra @JonB I would like to have initial position in one character. I don't want to have fixed size. The initial position is important because initial size of the main window comes from 9 edits in line.
-
@Northsoft As @JonB said the width of you line edit depends on the used font.
-
@jsulm I would like to use default font. Is there any way to get a maximum size of a single digit (0-9) without using multiple QPixMap's?
-
@Northsoft Take a look at https://doc.qt.io/qt-5/qfontmetrics.html
-
@jsulm thanks a lot, looks like what I need. The last questions are:
ā how can I convert width of displayed char to width of QLineEdit instance;
ā and how can I set it as default width? I don't see property for default size. -