Results 1 to 2 of 2

Thread: call to QLinearGradient::setColorAt() is ambigous

  1. #1
    Join Date
    Nov 2007
    Posts
    291
    Thanks
    85
    Thanked 1 Time in 1 Post

    Default call to QLinearGradient::setColorAt() is ambigous

    Hi
    The following line of code gives error
    Qt Code:
    1. QLinearGradient grad(rect().topLeft() + (rect().topLeft()-rect().bottomLeft()) / 2,
    2. (rect().topRight()-rect().bottomRight()) / 2);
    3. grad.setColorAt(0.0,0x000000); //Gives error
    To copy to clipboard, switch view to plain text mode 

    The error is
    Qt Code:
    1. mainwindow.cpp: In member function ‘virtual void MainWindow::paintEvent(QPaintEvent*)’:
    2. mainwindow.cpp:103: error: conversion from ‘int’ to ‘const QColor’ is ambiguous
    3. ../../qtsdk-2009.01/qt/include/QtGui/qcolor.h:79: note: candidates are: QColor::QColor(QColor::Spec) <near match>
    4. ../../qtsdk-2009.01/qt/include/QtGui/qcolor.h:252: note: QColor::QColor(const char*)
    5. ../../qtsdk-2009.01/qt/include/QtGui/qcolor.h:75: note: QColor::QColor(QRgb)
    6. ../../qtsdk-2009.01/qt/include/QtGui/qcolor.h:73: note: QColor::QColor(Qt::GlobalColor) <near match>
    To copy to clipboard, switch view to plain text mode 

    But when i modify the statement to
    Qt Code:
    1. grad.setColorAt(0.0,0x000001); //No error - changed 0x000000 to 0x000001
    To copy to clipboard, switch view to plain text mode 
    I get no error.

    why does this happen?.Is it so because the compiler sees enum as ints(please correct me if i am wrong). If that is the case then there can not be two constructors with enum arguments to a class as in QColor (QColor(Qt::GlobalColor color) and QColor(Spec spec)).

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: call to QLinearGradient::setColorAt() is ambigous

    Strange. But more strange is that you also have another constructor with an int: QColor ( QRgb color ). Since QRgb is defined as a unsigned int.

Similar Threads

  1. what if qthread call same slot at the same time?
    By zl2k in forum Qt Programming
    Replies: 2
    Last Post: 11th September 2008, 09:58
  2. call the other dialog through dialog
    By narumi in forum Qt Programming
    Replies: 2
    Last Post: 3rd September 2008, 09:30
  3. Replies: 1
    Last Post: 28th May 2008, 16:52
  4. how to call parent widget's event ?
    By rajeshs in forum Qt Programming
    Replies: 1
    Last Post: 20th December 2007, 12:39
  5. why cant i call setGeometry
    By freegnu in forum Qt Programming
    Replies: 1
    Last Post: 14th June 2006, 04:59

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
  •  
Qt is a trademark of The Qt Company.