How may I set the visible width of QLineEdit with Qt 4.8.1 and up. Example would be to set the visible width to some pixel size or character width. I wish to only use C++ not QML.
My thought is in the direction of this block:
QHBoxLayout *nameRow = new QHBoxLayout;
QLineEdit *firstNameText = new QLineEdit,
*middleIntText = new QLineEdit,
*lastNameText = new QLineEdit;
//Whatever method is needed here to edit visible width
//firstNameText->???
//middleIntText->???
//lastNameText->???
nameRow->addWidget(firstNameText);
nameRow->addWidget(middleIntText);
nameRow->addWidget(lastNameText);
layout->addLayout(nameRow);
QWidget window;
window.setLayout(layout);
window.show();
Answer Update: (or see below)
firstNameText->setMaximumWidth(100);
firstNameText->setFixedWidth(120);
middleIntText->setMaximumWidth(50);
middleIntText->setFixedWidth(60);
lastNameText->setMaximumWidth(100);
lastNameText->setFixedWidth(120);
firstNameText->setMaximumWidth(100);
firstNameText->setFixedWidth(120);
You can use thse two functions and they will adjust the width accordingly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With