Note that there are some explanatory texts on larger screens.

plurals
  1. POerror while comparing a QString
    text
    copied!<p>im trying to write a simple loggin form in Qt . its supposed to open another form if the username and password are right . but its acting really weird heres my code :</p> <pre><code>login::login(QWidget *parent) : QDialog(parent) { QPushButton * login_button = new QPushButton; QPushButton * exit = new QPushButton; login_button-&gt;setText("LOGIN"); exit-&gt;setText("EXIT"); QLineEdit * username = new QLineEdit; QLineEdit * password = new QLineEdit; QVBoxLayout * login_layout = new QVBoxLayout ; QHBoxLayout * button_layout = new QHBoxLayout ; username-&gt;setText("Enter Username ..."); password-&gt;setText("Enter Password ... "); exit-&gt;connect(exit,SIGNAL(pressed()),this , SLOT(close())); login_layout-&gt;addWidget(username); login_layout-&gt;addWidget(password); button_layout-&gt;addWidget(login_button); button_layout-&gt;addWidget(exit); login_layout-&gt;addLayout(button_layout); this-&gt;setLayout(login_layout); this-&gt;connect(login_button,SIGNAL(clicked()),this,SLOT(finduser())); } void login::finduser() { if (username-&gt;text().compare("admin")) // &lt;---- problem !! emit showmanage() ; return; } </code></pre> <p>finduser is a SLOT for my dialog class . it emits the "showmanage" signal which opens the form im willing to open . the actual problem is in the if statement . i have no idea why but when it runs it causes my windows to crash . this also doesnt work :</p> <pre><code>void login::finduser() { if (username-&gt;text()=="admin") // &lt;---- problem !! emit showmanage() ; return; } </code></pre> <p>i have no idea what im doing wrong also heres the debug message : the inferior stopped because it recievd a signal from operating system signal name : sigsegv signal meaning : segmentation fault</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload