Results 1 to 4 of 4

Thread: QColorDialog

  1. #1
    Join Date
    Feb 2008
    Posts
    15
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default QColorDialog

    I was experimenting with the QColorDialog, and it works, but when I selected "Named Colors" in the comboBox that's in the dialog, I get a segmentation fault. All the other selections are fine. The color dialog looks different that the Qt4 doc I found, this isn't even in the picture of the dialog it shows. I'm using Qt4.6. What is this "Named Colors" selection, and how do I use it (or disable it)?

    (I was just trying to get the #rrggbb string, and it does work, except for the above problem.)


    QColor color = QColorDialog::getColor(Qt::black, this);
    if(color.isValid())
    {
    textColorName = color.name();
    QMessageBox::information(this, "Text Color", "You selected "+textColorName);
    }

  2. #2
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QColorDialog

    I get a segfault also. It seems to be a problem with the KDE native dialog. On my machine the dialog looks like the pic in the docs in Gnome and if QColorDialog::DontUseNativeDialog is set in KDE.

    Can't help with the "Named Colors".

  3. The following user says thank you to norobro for this useful post:

    BrainFreeze (6th March 2011)

  4. #3
    Join Date
    Feb 2008
    Posts
    15
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QColorDialog

    Ok, that works! It took me a while to figure out how to write to proper code, but here's what I did to get it working:

    Qt Code:
    1. void MainWindow::onColor()
    2. {
    3. QColor color = QColorDialog::getColor(Qt::black, this, "Text Color", QColorDialog::DontUseNativeDialog);
    4. if(color.isValid())
    5. {
    6. textColorName = color.name();
    7. QMessageBox::information(this, "Text Color", "You selected "+textColorName);
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 

    Thanks for your help!
    Last edited by BrainFreeze; 6th March 2011 at 05:01.

  5. #4
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QColorDialog

    Hover your mouse over the icons above the text box. For example the left "#" is for code tags.

  6. The following user says thank you to norobro for this useful post:

    BrainFreeze (6th March 2011)

Similar Threads

  1. Embed QColorDialog as a widget
    By totem in forum Qt Programming
    Replies: 2
    Last Post: 23rd January 2010, 00:40
  2. QColorDialog always return 0 as a result
    By NoRulez in forum Qt Programming
    Replies: 8
    Last Post: 17th October 2009, 12:06
  3. Using <QColorDialog>
    By Gily in forum Newbie
    Replies: 5
    Last Post: 26th December 2007, 20:26
  4. Please help ASAP::QColorDialog
    By LiCodeX in forum Newbie
    Replies: 2
    Last Post: 2nd October 2007, 12:16
  5. QColorDialog Apperance?
    By antonio.r.tome in forum Qt Programming
    Replies: 9
    Last Post: 16th April 2006, 07:43

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.