Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Qt 4.8 | EchoMode-仅显示一个字符,而不是所有字符_C++_Qt_Qlineedit_Qt4.8 - Fatal编程技术网

C++ Qt 4.8 | EchoMode-仅显示一个字符,而不是所有字符

C++ Qt 4.8 | EchoMode-仅显示一个字符,而不是所有字符,c++,qt,qlineedit,qt4.8,C++,Qt,Qlineedit,Qt4.8,我在找一个好主意 我想创建一个QLineEdit字段,当数字超过999999时,该字段应仅显示一个字符(“p”)。 我有一个字段,显示每个字符的字母“P”。可能我忘记了一些信息,让我知道你需要什么。 该想法正在发挥作用,请参见所附图片。但正如你在第二张图中看到的,我只想要一个“P”。 为了进一步理解,此字段表示半径。是半径大于999999的值,曲面为平面=P #包括“newWindow.h” #包括 #包括 #包括 #包括 newPassword::newPassword(QWidget*p

我在找一个好主意

我想创建一个QLineEdit字段,当数字超过999999时,该字段应仅显示一个字符(“p”)。 我有一个字段,显示每个字符的字母“P”。可能我忘记了一些信息,让我知道你需要什么。 该想法正在发挥作用,请参见所附图片。但正如你在第二张图中看到的,我只想要一个“P”。 为了进一步理解,此字段表示半径。是半径大于999999的值,曲面为平面=P

#包括“newWindow.h”
#包括
#包括
#包括
#包括
newPassword::newPassword(QWidget*parent):QWidget(parent)
{
标签1=新的QLabel(“Eingabe1”);
标签2=新的QLabel(“Eingabe2”);
lineIn1=新的QLineEdit(“Eingabe1”);
lineIn2=新的QLineEdit;
QValidator*validator=新的QIntValidator(0,9999999999999999,this);
lineIn2->setValidator(验证器);
VBox=新的QVbox布局;
VBox->addWidget(标签1);
VBox->addWidget(标签2);
VBox->addWidget(第1行);
VBox->addWidget(lineIn2);
连接(lineIn2,信号(returnPressed()),此,插槽(updateText());
设置布局(VBox);
setWindowTitle(“密码QLineEdit”);
}
void newPassword::updateText()
{
双var1;
var1=lineIn2->text().toDouble();
如果(var1>99999)
{
lineIn2->setEchoMode(QLineEdit::Password);
lineIn2->setStyleSheet(QString(“QLineEdit[echoMode=\“2\”]{lineedit密码字符:0080}”);
//lineIn2->setMaxLength(1);//
//lineIn2->setVisible(假)//
//lineIn2->setMask();
}
其他的
{
lineIn2->setEchoMode(QLineEdit::Normal);
}
labelIn2->setText(lineIn2->text());
}
#include "newWindow.h"
#include <QApplication>
#include <QMessageBox>
#include <QLatin1Char>
#include <QIntValidator>


newPassword::newPassword(QWidget *parent) : QWidget(parent)
{
  labelIn1 = new QLabel("Eingabe1");
  labelIn2 = new QLabel("Eingabe2");
  lineIn1 = new QLineEdit("Eingabe1");
  lineIn2 = new QLineEdit;
  QValidator *validator = new QIntValidator(0, 99999999999999, this);
  lineIn2->setValidator(validator);
  VBox = new QVBoxLayout;
  VBox->addWidget(labelIn1);
  VBox->addWidget(labelIn2);
  VBox->addWidget(lineIn1);
  VBox->addWidget(lineIn2);
  connect(lineIn2, SIGNAL(returnPressed()),this,SLOT(updateText()));

  setLayout(VBox);
  setWindowTitle("Password QLineEdit");
}

void newPassword::updateText()
{
  double var1;
  var1 = lineIn2->text().toDouble();

  if (var1 > 999999)
  {
    lineIn2->setEchoMode(QLineEdit::Password); 
    lineIn2->setStyleSheet(QString("QLineEdit[echoMode=\"2\"]{lineedit-password-character:0080}"));
    //lineIn2->setMaxLength(1); // 
    //lineIn2->setVisible(false); //
    //lineIn2->setMask();
  }
  else
  {
    lineIn2->setEchoMode(QLineEdit::Normal); 
  }
    labelIn2->setText(lineIn2->text());
}