Results 1 to 2 of 2

Thread: QColorDialog background color help.

  1. #1
    Join Date
    May 2017
    Posts
    1
    Qt products
    Qt5 Qt/Embedded

    Default QColorDialog background color help.

    Hi, Hoping someone can help me out. Im pretty new to QT and developing an App to run on the Raspberry Pi.. SO far, all great, but have an issue with using the QColorDialog. In my application, my mainwindow.ui background is black, and when i open a QColorDialog, it inherits the same background color. Ive tried using a stylesheet and that doesnt work.. Ive used the QColorDialog:OntUseNativeDialog to force the use of QT's version.

    QColorDialog mycolordialog;
    mycolordialog.setStyleSheet("background-color:grey");
    QColor color = mycolordialog.getColor(Qt::white, this, "Effect Color", QColorDialog:ontUseNativeDialog);


    Can anyone tell me why i cant change the background of the color picker to grey ?

    Thanks !


    Pete

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QColorDialog background color help.

    QColorDialog::getColor() is a static member of the QColorDialog class. Even though you are calling it using a reference to an instance of a QColorDialog class (mycolordialog) it cannot use any of the properties you have set on that instance since the method is static and does not use any instance when it is called.

    If you want your changes to be used, then you have to call a non-static member, such as QDialog::exec() and then retrieve the chosen color (using QColorDialog::selectedColor()) after exec() returns with an "Accepted" value.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. QColorDialog, Custom Color, Stored where and how to delete?
    By HappyCoder in forum Qt Programming
    Replies: 1
    Last Post: 17th November 2015, 16:54
  2. Get background color of QPushbutton
    By MickyJhon in forum Qt Programming
    Replies: 6
    Last Post: 7th February 2014, 17:45
  3. Background color
    By FelixB in forum Qwt
    Replies: 4
    Last Post: 24th June 2013, 08:03
  4. Replies: 2
    Last Post: 6th May 2010, 15:09
  5. Qt4 - QTextEdit - background color
    By impeteperry in forum Qt Programming
    Replies: 9
    Last Post: 29th January 2009, 08:52

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.