QImage::bits() overloaded function
Hello!
In QImage class we have function bits() witch is overloaded:
Code:
uchar * bits ()
const uchar * bits () const
My problem is that when I want to call uchar * bits () function, just like that:
Code:
uchar *bitsImage = image.bits();
I'm getting an error:
error: invalid conversion from 'const uchar*' to 'uchar*'
So I would like to ask how I can call the uchar * bits () function?
Best regards
s410i
Re: QImage::bits() overloaded function
Quote:
Originally Posted by
s410i
Hello!
In QImage class we have function bits() witch is overloaded:
Code:
uchar * bits ()
const uchar * bits () const
My problem is that when I want to call uchar * bits () function, just like that:
Code:
uchar *bitsImage = image.bits();
I'm getting an error:
error: invalid conversion from 'const uchar*' to 'uchar*'
So I would like to ask how I can call the uchar * bits () function?
Best regards
s410i
Although its strange.
Anyway you can use casting operators. e.g.
Code:
uchar *bitsImage = const_cast <uchar*> image.bits();
Re: QImage::bits() overloaded function
Quote:
Originally Posted by
s410i
So I would like to ask how I can call the uchar * bits () function
This works fine for me:
Code:
#include <QImage>
int main(){
uchar *bits = img.bits();
return 0;
}
Your "image" variable is probably const. You can't call non-const methods on a const object.
Re: QImage::bits() overloaded function
Thank you very much :)
const QImage was the problem.
Best regards
s410i