is there any way to insert QPixmap object in html?

后端 未结 4 1069
后悔当初
后悔当初 2021-01-05 22:54

Simple situation: I have an object, which has a QPixmap member. Object first created (pixmap is null now), then pixmap readed from data base and inserted in obj

4条回答
  •  没有蜡笔的小新
    2021-01-05 22:55

    I put this in another answer to be able to format the code. I wrote the following program and it works as intended:

    #include 
    
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
        QWidget window;
        window.resize(320, 240);
        window.show();
        window.setWindowTitle(
            QApplication::translate("toplevel", "Top-level widget"));
        QLabel* label = new QLabel(&window);
        label->setTextFormat(Qt::RichText);
        QString text = "

    Test

    here is an image: "; QPixmap pixmap("testicon.jpg"); QByteArray byteArray; QBuffer buffer(&byteArray); pixmap.save(&buffer, "PNG"); QString url = QString(""; text += url; text += ""; label->setText(text); label->move(100, 100); label->show(); return app.exec(); }

提交回复
热议问题