예제 #1
0
void LoginDialog::setUpGUI()
{
    QGridLayout* formGridLayout = new QGridLayout(this);

    comboUsername = new QComboBox(this);
    comboUsername->setEditable(true);

    editPassword = new QLineEdit(this);
    editPassword->setEchoMode(QLineEdit::Password);

    labelDescription = new QLabel(this);
    labelUsername = new QLabel(this);
    labelPassword = new QLabel(this);
    labelUsername->setText(tr("Username"));
    labelUsername->setBuddy(comboUsername);
    labelPassword->setText(tr("Password"));
    labelPassword->setBuddy(editPassword);

    buttons = new QDialogButtonBox(this);
    buttons->addButton(QDialogButtonBox::Ok);
    buttons->addButton(QDialogButtonBox::Cancel);

    connect(buttons->button(QDialogButtonBox::Cancel),
            SIGNAL(clicked()),
            this, SLOT(close()));

    connect(buttons->button(QDialogButtonBox::Ok),
            SIGNAL(clicked()),
            this, SLOT(slotAcceptLogin()));

    formGridLayout->addWidget(labelDescription, 0, 0, 1, 3);
    formGridLayout->addWidget(labelUsername, 1, 0);
    formGridLayout->addWidget(comboUsername, 1, 1);
    formGridLayout->addWidget(labelPassword, 2, 0);
    formGridLayout->addWidget(editPassword, 2, 1);
    formGridLayout->addWidget(buttons, 3, 0, 1, 2);

    setLayout(formGridLayout);
}
예제 #2
0
void LoginDialog::setUpGUI() {
    // set up the layout
    formGridLayout = new QGridLayout( this );

    editUsername = new QLineEdit( this );
    editPassword = new QLineEdit( this );
    editPassword->setEchoMode( QLineEdit::Password );

    // initialize the labels
    labelUsername = new QLabel( this );
    labelPassword = new QLabel( this );
    labelUsername->setText( tr( "Имя пользователя" ) );
    labelUsername->setBuddy( editUsername );
    labelPassword->setText( tr( "Пароль" ) );
    labelPassword->setBuddy( editPassword );

    // initialize buttons
    buttons = new QDialogButtonBox( this );
    buttons->addButton( QDialogButtonBox::Ok );
    buttons->button( QDialogButtonBox::Ok )->setText( tr("Login") );

    connect( buttons->button( QDialogButtonBox::Ok ),
             SIGNAL(clicked()),
             this,
             SLOT(slotAcceptLogin()) );

    errorLabel = new QLabel(this);
    errorLabel->setText( tr( "" ) );

    // place components into the dialog
    formGridLayout->addWidget( errorLabel, 0, 0 );
    formGridLayout->addWidget( labelUsername, 1, 0 );
    formGridLayout->addWidget( editUsername, 1, 1 );
    formGridLayout->addWidget( labelPassword, 2, 0 );
    formGridLayout->addWidget( editPassword, 2, 1 );
    formGridLayout->addWidget( buttons, 3, 0, 1, 2 );

    setLayout( formGridLayout );
}