Results 1 to 11 of 11

Thread: Changing appearence of mainwindow according to end user

  1. #1
    Join Date
    May 2012
    Posts
    33
    Thanks
    9
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Changing appearence of mainwindow according to end user

    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

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Changing appearence of mainwindow according to end user

    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Changing appearence of mainwindow according to end user

    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  4. #4
    Join Date
    May 2012
    Posts
    33
    Thanks
    9
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Changing appearence of mainwindow according to end user

    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.

  5. #5
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Changing appearence of mainwindow according to end user

    Don't see the problem... You can generate QSS on-the-fly... Or use Amleto's suggestion.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  6. #6
    Join Date
    May 2012
    Posts
    33
    Thanks
    9
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Changing appearence of mainwindow according to end user

    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...

  7. #7
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Changing appearence of mainwindow according to end user

    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.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  8. The following user says thank you to spirit for this useful post:

    prabhudev (3rd August 2012)

  9. #8
    Join Date
    May 2012
    Posts
    33
    Thanks
    9
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Changing appearence of mainwindow according to end user

    Hey..I used this,but whatever i give as input.. blue, white,yellow..it sets it as black itself..
    Qt Code:
    1. void MainWindow::on_Set_clicked()
    2. {
    3. s=ui->bcolor->text();//textbox from wher i get input from user
    4. qApp->setStyleSheet("QLineEdit { background-color:s }");
    5.  
    6. }
    To copy to clipboard, switch view to plain text mode 

  10. #9
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Changing appearence of mainwindow according to end user

    I would change the code like this:
    Qt Code:
    1. void MainWindow::on_Set_clicked()
    2. {
    3. s=ui->bcolor->text();//textbox from wher i get input from user
    4. qApp->setStyleSheet(QString("QLineEdit { background-color:%1 }").arg(s));
    5. }
    To copy to clipboard, switch view to plain text mode 
    You would also need to check entered value in a lineEdit or use QColorDialog with QColor::name to select necessary color.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  11. The following user says thank you to spirit for this useful post:

    prabhudev (3rd August 2012)

  12. #10
    Join Date
    May 2012
    Posts
    33
    Thanks
    9
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Changing appearence of mainwindow according to end user

    Thanks..It worked..
    spirit U Rock!!!

  13. #11
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Changing appearence of mainwindow according to end user

    You are welcome. It's not me, it's docs
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

Similar Threads

  1. Android Installation - how and where to add/store changing user files?
    By sedi in forum Installation and Deployment
    Replies: 2
    Last Post: 13th June 2012, 16:58
  2. Changing MainWindow UI from another QThread.
    By EdgeLuxe in forum Newbie
    Replies: 1
    Last Post: 4th September 2010, 15:35
  3. resizing widgets when user resizes mainwindow
    By Mystical Groovy in forum Qt Programming
    Replies: 13
    Last Post: 21st December 2009, 00:03
  4. resizing graphicsView when user resizes mainwindow
    By mirelon in forum Qt Programming
    Replies: 0
    Last Post: 20th December 2009, 22:43
  5. Replies: 3
    Last Post: 15th November 2007, 13:09

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.