Reputation: 81
I want to change the borders of my textboxes if they are not field. So I do a simple check and the change styles like this:
if(!ui->TextBoxPhone->text().isEmpty() && !ui->TextBoxAddress->text().isEmpty()) {
cout<<"Saved fine \n";
}
else {
if(ui->TextBoxPhone->text().isEmpty()) {
ui->TextBoxPhone->setStyleSheet("border: 2px solid red");
}
if(ui->TextBoxAddress->text().isEmpty()) {
ui->TextBoxAddress->setStyleSheet("border: 2px solid red");
}
}
So the problem I have is that the stylesheet would not update automaticly. It will update however if I click elsewhere. I already tried using
ui->TextBoxName->style()->unpolish(ui->TextBoxName);
ui->TextBoxName->style()->polish(ui->TextBoxName);
ui->TextBoxName->update();
No luck. Might it be a macbook isue?
here are some screenshots:
as you can see left-border is red
when I click on another textbox both of them update and become red
Upvotes: 1
Views: 3586
Reputation: 81
Solved it... repaint() method did the job;
ui->TextBoxPhone->repaint();
Upvotes: 2
Reputation: 8698
Works for me:
myTextEdit->setStyleSheet("QTextEdit{background: transparent; border: none;}");
Nothing else needed. Make sure to specify correct type for the stylesheet. Or maybe even this will resolve:
myTextEdit->setStyleSheet("{background: transparent; border: none;}");
Upvotes: 0