Results 1 to 6 of 6

Thread: Setting style sheet of ui in main window class from dialog class

  1. #1
    Join Date
    Dec 2012
    Posts
    45
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Default Setting style sheet of ui in main window class from dialog class

    I want to set style sheet of ui in main window class form a dilog class which opens another ui.
    Here is my sample code
    dialog.cppdialog.hmainwindow.cppmainwindow.h

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Setting style sheet of ui in main window class from dialog class

    You don't say what your problem is, so I am guessing: move the signal/slot connect before the call to exec()

    Qt Code:
    1. Dialog *d = new Dialog;
    2. connect(d, SIGNAL(update(QString)),this,SLOT(Set_style_Sheet(QString)));
    3. d->exec();
    To copy to clipboard, switch view to plain text mode 

    Btw, creating a dialog with new and not deleting it results in memory loss.

    Cheers,
    _

  3. #3
    Join Date
    Dec 2012
    Posts
    45
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: Setting style sheet of ui in main window class from dialog class

    My problem was that i was unable to change the color form the dialog class, thanks your suggestion helped me, now i want that the changed style sheet to be loaded next time when i execute program can you suggest me a way to do so

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Setting style sheet of ui in main window class from dialog class

    Save it on change or program exit and load and apply on program startup?
    Using QSettings maybe?

    Cheers,
    _

  5. #5
    Join Date
    Dec 2012
    Posts
    45
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: Setting style sheet of ui in main window class from dialog class

    I want to save it on change and the new setting to be reflected at the same time also when the program is reloaded it should run with the changed setting

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Setting style sheet of ui in main window class from dialog class

    Then you save it on change and load it on startup.

    You can do the saving in the Set_style_Sheet slot. You can do the loading in the window's constructor.

    Cheers,
    _

Similar Threads

  1. Replies: 1
    Last Post: 3rd October 2012, 09:56
  2. Replies: 5
    Last Post: 27th July 2012, 08:21
  3. Replies: 1
    Last Post: 20th January 2012, 05:39
  4. Replies: 0
    Last Post: 8th March 2011, 23:08
  5. Replies: 4
    Last Post: 26th June 2007, 20:19

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.