尝试上传图片时出现此错误进程1780056901(Zain)已终止SIGSEGV代码= 1 fltno = 11 ip = 00000000。我没有得到黑莓论坛的帮助,而且大多数黑莓文档都在垃圾箱旁边。他们提供的许多代码都是错误的文档并且不起作用。
void ApplicationUI::getPicture()
{
FilePicker* filePicker = new FilePicker();
filePicker->setType(FileType::Picture);
filePicker->setTitle("Select Picture");
filePicker->setMode(FilePickerMode::Picker);
filePicker->open();
QObject::connect(filePicker,
SIGNAL(fileSelected(const QStringList&)),
this,
SLOT(onFileSelected(const QStringList&)));
}
void ApplicationUI::onFileSelected(const QStringList& list) {
try
{
QFile file (list[0]);
ImageView* ay = root->findChild<ImageView*>("imageName");
if(ay != NULL)
ay->setImage(Image(list[0]));
QString body = "" ;
QSettings settings("Netvariant", "Zain");
QString locale_string = settings.value("lang").toString();
if(locale_string == "ar")
locale_string == "ar";
else
locale_string = "en";
const QUrl url("myurl");
QHttpPart imagePart;
imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpeg"));
imagePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"imageFile\""));
imagePart.setRawHeader("Content-ID", "my@content.id"); // add any headers you like via setRawHeader()
file.open(QIODevice::ReadOnly);
imagePart.setBodyDevice(&file);
QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);
file.setParent(multiPart); // we cannot delete the file now, so delete it with the multiPart
multiPart->append(imagePart);
QNetworkRequest request(url);
QNetworkAccessManager* netManager = new QNetworkAccessManager(this);
QNetworkReply *reply = netManager->post(request, multiPart);
}
catch(...)
{
}
}