QLineEditの可視幅をQt 4.8.1以上に設定するにはどうすればいいですか?例としては、可視の幅をピクセルサイズまたは文字幅に設定することです。 QMLではなくC++のみを使用したいと考えています。QLineEdit可視幅の設定?
私の考えは、このブロックの方向にあります。
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();
回答アップデート:(または下記参照)
firstNameText->setMaximumWidth(100);
firstNameText->setFixedWidth(120);
middleIntText->setMaximumWidth(50);
middleIntText->setFixedWidth(60);
lastNameText->setMaximumWidth(100);
lastNameText->setFixedWidth(120);
ウィジェットの実際の幅に関係なく、コンテンツ領域を特定のサイズに切り詰めたいとお考えですか?それでもデータサイズとウィジェットの幅は許可したいがコンテンツ領域の幅は許可したくない? – jdi