[Solved] QLineEdit visible width setting?
-
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:
@ firstNameText->setMaximumWidth(100);
firstNameText->setFixedWidth(120);
middleIntText->setMaximumWidth(50);
middleIntText->setFixedWidth(60);
lastNameText->setMaximumWidth(100);
lastNameText->setFixedWidth(120);@
Thanks to a user at "StackOverflow":http://stackoverflow.com/questions/11515661/qlineedit-visible-width-setting/11515830#11515830Brandon Clark
-
@ firstNameText->setMaximumWidth(100);
firstNameText->setFixedWidth(120);
middleIntText->setMaximumWidth(50);
middleIntText->setFixedWidth(60);
lastNameText->setMaximumWidth(100);
lastNameText->setFixedWidth(120);@Thanks to a user at "StackOverflow":http://stackoverflow.com/questions/11515661/qlineedit-visible-width-setting/11515830#11515830
-
setFixedWidth will set both min and maximum width, so doing setMaximumWidth before is redundant.