开发者

view an image in qt for symbian

开发者 https://www.devze.com 2023-04-05 08:43 出处:网络
I have an application that I implemented, and want to display an image in a widget, but I get an error SIGSEGV, I view it from a directory, but in reality after heave from a buffer

I have an application that I implemented, and want to display an image in a widget, but I get an error SIGSEGV, I view it from a directory, but in reality after heave from a buffer not what the problem is I leave my code here:

void Image:: on_pushButton_clicked ()
{

     this-> conn-> connect (this-> ui-> lineEdit_2-> text (),
                      this-> ui-> lineEdit-> text (). Toint ()); QLayout* layout;

        QString fileName = QFileDialog:: GetOpenFileName (this,
                                                        tr ("Open File"), QDir:: currentPath (),
                                                        "files (*. jpg *. png)");

        QImage image (fileName);

  开发者_C百科      QLabel * label = new QLabel (this);
        label-> setPixmap (QPixmap:: FromImage (image));

        label-> setScaledContents (true);

        layout-> addWidget (label);
        label-> show ();

}

I can leave if you want to help my application link for the download thank you very much


thank you very much and I managed to see the image, I want to load from a buffer like this: QBuffer * buffer = new QBuffer (conex); QImage * image = new QImage (); image-> loadFromData (buffer-> buffer ());


I tried this to make my image but I get errors QBuffer * buffer = new QBuffer (conn); QImage image = new QImage (); image-> loadFromData (buffer-> buffer ()); errors are as follows: C:\ejemplos_qt\teratermobile-build-simulator..\teratermobile\imagen.cpp:81: error: conversion from 'QImage*' to non-scalar type 'QImage' requested C:\ejemplos_qt\teratermobile-build-simulator..\teratermobile\imagen.cpp:82: error: base operand of '->' has non-pointer type 'QImage'


You didn't initialize your layout variable before using it with something like this:

layout = new QVBoxLayout(widget); // widget is where you want to put the QLabel

or you can reuse an already created layout.

If you want to show the QLabel as a top-level window, remove completely the two lines about the layout.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号