Results 1 to 7 of 7

Thread: QImage::fill can't digest what I feed it

  1. #1
    Join Date
    Jan 2012
    Location
    San Diego, California
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QImage::fill can't digest what I feed it

    I am stumped by this compile error, sure that it's some very simple "obvious" doof-up. I'm hoping to create an image filled with a color.

    QImage qim( QSize(24,24), QImage::Format_ARGB32 );
    qim.fill( QColor("#FFD07F") );

    The compiler from Visual Studio 10 (using command line tools) gripes with:

    main.cpp(51) : error C2664: 'QImage::fill' : cannot convert parameter 1 from 'QColor' to 'uint'

    Line 51 being the qim.fill() call. The Qt doc for QImage says QImage::fille(const QColor &) exists, and QColor should be fine with a string containing web-style color like that. It sure looks like everything is fine in the source code.

    What the heck is the problem?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QImage::fill can't digest what I feed it

    Curious. GCC compiles this without issue on Linux and Windows, as you would expect.
    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char **argv)
    4. {
    5. QApplication app(argc, argv);
    6. QImage qim( QSize(24,24), QImage::Format_ARGB32 );
    7. qim.fill( QColor("#FFD07F") );
    8. return 0;
    9. }
    To copy to clipboard, switch view to plain text mode 
    Does your compiler choke on the example above?

  3. #3
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    507
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QImage::fill can't digest what I feed it

    Hi, which Qt version do you use?
    QImage::fill(const QColor & color) has been introduced with Qt 4.8, so if you use an earlier version, you compiler is correct

    Ginsengelf

  4. #4
    Join Date
    Jan 2012
    Location
    San Diego, California
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QImage::fill can't digest what I feed it

    Yes, my compiler, from Visual Studio 10, chokes on that simple example. Qt is 4.7.4 on a 64-bit Windows 7 machine.
    Here is the error:


    .\c.cpp(7) : error C2664: 'QImage::fill' : cannot convert parameter 1 from 'QColor' to 'uint'
    No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
    NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\x86_amd64\cl.EXE"' : return code '0x
    2'
    Stop.
    NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\nmake.exe"' : return code '0x2'
    Stop.


    It should be noted that I am a long-time linux user, familiar with gcc and clang (and some obscure tools on unix-like platforms). My most recent experience with anything Microsoft goes back to 2001 or so, not counting the current job and some minor incidents, so I'm ignorant of the various quirks of the system. I build by writing C++ source, running qmake -project, qmake and nmake.

    BTW, s/fille/fill/ in the OP. Fat clumsy fingers, I have.

  5. #5
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QImage::fill can't digest what I feed it

    Qt 4.7.4 has no a function which takes QColor in QImage::fill. That method was introduced in Qt 4.8 as Ginsengelf said above.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  6. #6
    Join Date
    Jan 2012
    Location
    San Diego, California
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QImage::fill can't digest what I feed it

    Astonishing! Seems like feeding a QColor to fill() would be such an obvious basic act it would have been in Qt since 0.x versions. Oh well.

    So, what's the easy no-brainer workaround in 4.7?

  7. #7
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QImage::fill can't digest what I feed it

    use qRgba or QColor::rgba.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

Similar Threads

  1. How do I remove the BusyIndicator after you read a feed?
    By LucioMSP in forum Qt Programming
    Replies: 0
    Last Post: 20th February 2012, 17:15
  2. Linguist: line feed
    By Markus_AC in forum Qt Tools
    Replies: 1
    Last Post: 10th October 2011, 21:18
  3. Replies: 1
    Last Post: 9th May 2011, 15:19
  4. How to stop form feed after printing
    By Prabha in forum Qt Programming
    Replies: 0
    Last Post: 17th August 2010, 10:30
  5. QTextEdit and Form Feed character
    By gvlaovic in forum Qt Programming
    Replies: 1
    Last Post: 15th September 2007, 12:37

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.