Is it possible to style a QinputDialog?
I have the following code:
void calibratemotors::on_pushButton_shuttopen_manualent_clicked()
{
bool ok;
double shutopen_manenter = QInputDialog::getDouble(this, "getDouble",
"Some Number:", 0.00, -10000, 10000, 2, &ok);
if (ok)
ui->label->setText(QString("%1").arg(shutopen_manenter));
}
The problem is, is it inherits aspects of "this", such as the background colour, border, etc. I tried to add the line:
this->setStyleSheet( "QInputDialog {background-color: red;}" );
on the click but that also changes the parent window as well, so is it possible to only trigger say the QInputDialog's background colour without effecting the parent? Right now I am getting this:
Before:
After:
Its like the background of the parent is being stripped and reverted back to default system colors.
Uses
QInputDialog
instead ofQMenu
. In this casesetStyleSheet( "QInputDialog {background-color: red;}" );
. A good practice is to indicate the widget to which it will affect. According to what you tell me your base widget isQDialog
.The "*" makes the style only apply to that widget and does not cascade to the others.
Here's an example.
Output: