Results 1 to 4 of 4

Thread: Widget Palette

  1. #1
    Join Date
    Jul 2008
    Posts
    139
    Thanks
    9
    Thanked 18 Times in 15 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Widget Palette

    Hi,
    Not sure if this post is in the right place. It is a basic question. I have created many ui forms in QtDesigner. I want each form to have the same palette. Right now I am just setting the palette in QtDesigner to custom, then put the same value in for each form. How can I globally set the palette for all my forms?
    Thanks in Advance.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Widget Palette

    You could construct the palette in code instead and set it to the whole application through QApplication::setPalette().
    J-P Nurmi

  3. #3
    Join Date
    Jul 2008
    Posts
    139
    Thanks
    9
    Thanked 18 Times in 15 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Widget Palette

    Thank you
    I thought maybe I might need this function QApplication::setPalette(). OK, but I look at the designer code for setting the palette and there is like 25 or more lines of code (for the buttons, background, on/off state, etc).
    Are you suggesting I put that same designer code outside my form in my window app? Maybe I am misunderstanding your response.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Widget Palette

    If you are not comfortable doing it in code, you could also keep it in one of the forms (the main window form would be the natural choice) and set it as application palette after loading the form, more or less like this:
    Qt Code:
    1. #include <QApplication>
    2.  
    3. MyMainWindow::MyMainWindow(QWidget* parent) : QMainWindow(parent)
    4. {
    5. ui.setupUi(this);
    6. QApplication::setPalette(palette());
    7. }
    To copy to clipboard, switch view to plain text mode 
    This would ensure that other forms inherit the same palette even if you don't explicitly define any.
    J-P Nurmi

Similar Threads

  1. QDockWidget inside another widget in the center?
    By Antebios in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2010, 07:06
  2. Widget Focus
    By navi1084 in forum Qt Programming
    Replies: 6
    Last Post: 29th September 2008, 10:22
  3. Playbutton functionality
    By uchennaanyanwu in forum Qt Programming
    Replies: 5
    Last Post: 31st July 2008, 22:29
  4. How to Open & Close a Widget ?!!
    By Fatla in forum Qt Programming
    Replies: 6
    Last Post: 13th June 2008, 20:39
  5. Tricky problem with ARGB widget / UpdateLayeredWindow
    By nooky59 in forum Qt Programming
    Replies: 3
    Last Post: 21st February 2008, 10:35

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.