hi
i has a button and a lineedit .
how do i change color lineedit per click ?
Printable View
hi
i has a button and a lineedit .
how do i change color lineedit per click ?
Quick way to be use stylesheets.
You can also change palette of the lineedit.
How do i do this? :(
Code:
void MainWindow::on_pushButton_clicked() { QString one , two , three , four ; one = "color : red" ; two = "color : pink" ; three = "color : green" ; four = "color : violet" ; if(stirng != '\0') { ui->lineEdit_2->setText(stirng); if(i==1) { ui->lineEdit_2->setStyleSheet(one); i++; } else if(i==2) { ui->lineEdit_2->setStyleSheet(two); i++; } else if(i==3) { ui->lineEdit_2->setStyleSheet(three); i++; } else { ui->lineEdit_2->setStyleSheet(four); i = 1 ; } } } int MainWindow::i = 1 ;
But not useful :(
What happens when you single-step through this code in your debugger? What do you think line 13 does?
When the user does not enter a string in qlineedit1 :-?Quote:
What do you think line 13 does?
Attachment 8898
use isEmpty() to check the LineEdit text
ex:Code:
if( !stirng.isEmpty()) { ............. }