PDA

View Full Version : Changing appearence of mainwindow according to end user



prabhudev
2nd August 2012, 09:48
Hi
I have GUI to which i want to give user the choice changing the colour of the mainwindow according to his wish. This means when the user runs the application i want to give him a settings button in which he can choose background color for the gui and font type for the gui etc. I dont know how to proceed... kindly help

spirit
2nd August 2012, 10:16
see Qt Style Sheets (http://qt-project.org/doc/qt-4.8/stylesheet.html).

amleto
2nd August 2012, 13:48
or QPalette

old thread:
http://www.qtcentre.org/threads/49146-Change-font-color-of-whole-application

prabhudev
3rd August 2012, 05:20
Thanks... But in stylesheets i found that i can change background color, ie if i change the gui to blue, it will be blue when the end user runs it. I want to give the end user the choice to change the background color, insted of me forcing a color of my choice on him.

spirit
3rd August 2012, 06:17
Don't see the problem... You can generate QSS on-the-fly... Or use Amleto's suggestion.

prabhudev
3rd August 2012, 10:59
The problem is i dont want hardcode the background color and font style of my choice . I want to give end user to have his choice changing the appearance ...like you set taskbar color in windows7... I hope i am clear this time...
Using stylesheet
background-color: rgb(42, 84, 127); //
it will set the background color to blue... end user cant change it...

I want to give him a settings button through which he can change the appearance...
When the user changes the color to red it should change immediately...

spirit
3rd August 2012, 11:01
Don't hard code it :) Use UI to change the color then set it into style sheet. Really don't get why it's so hard for you. :)

prabhudev
3rd August 2012, 11:16
Hey..I used this,but whatever i give as input.. blue, white,yellow..it sets it as black itself..

void MainWindow::on_Set_clicked()
{
QString s;
s=ui->bcolor->text();//textbox from wher i get input from user
qApp->setStyleSheet("QLineEdit { background-color:s }");

}

spirit
3rd August 2012, 11:20
I would change the code like this:


void MainWindow::on_Set_clicked()
{
QString s;
s=ui->bcolor->text();//textbox from wher i get input from user
qApp->setStyleSheet(QString("QLineEdit { background-color:%1 }").arg(s));
}

You would also need to check entered value in a lineEdit or use QColorDialog with QColor::name to select necessary color.

prabhudev
3rd August 2012, 11:40
Thanks..It worked..
spirit U Rock!!!

spirit
3rd August 2012, 11:41
You are welcome. It's not me, it's docs ;)