Display QImage with QtGui

后端 未结 5 1442
忘了有多久
忘了有多久 2020-12-02 09:01

I am new to Qt, and I am trying to create a simple GUI Application that displays an image once a button has been clicked on.

I can read the image in a QImage

5条回答
  •  感情败类
    2020-12-02 09:49

    Simple, but complete example showing how to display QImage might look like this:

    #include 
    #include 
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
    
        QImage myImage;
        myImage.load("test.png");
    
        QLabel myLabel;
        myLabel.setPixmap(QPixmap::fromImage(myImage));
    
        myLabel.show();
    
        return a.exec();
    }
    

提交回复
热议问题