MainWindow::MainWindow(QString path) { QPalette* palette = new QPalette(); // palette->setBrush(QPalette::Background,*(new QBrush(*(new QPixmap(path+"/res/background.jpg"))))); setPalette(*palette); setWindowTitle("Alzekr"); resize(1024,819); //QLabel *qlabel=createLabel(); QTextDocument *textDocument=new QTextDocument; QVBoxLayout *vbox=new QVBoxLayout; //------------------------------------------------------------------------------------- QTextEdit *editor = new QTextEdit; QTextDocument *document = new QTextDocument(editor); QTextCursor cursor(document); QImage image(64, 64, QImage::Format_RGB32); image.fill(qRgb(255, 160, 128)); //! [Adding a resource] document->addResource(QTextDocument::ImageResource, QUrl("mydata://image.png"), QVariant(image)); document->setPageSize(QSize(100,200)); //! [Adding a resource] //! [Inserting an image with a cursor] QTextImageFormat imageFormat; imageFormat.setName("mydata://image.png"); cursor.insertImage(imageFormat); //! [Inserting an image with a cursor] cursor.insertBlock(); cursor.insertText("Code less. Create more."); editor->document()->setPageSize( QSizeF( 100, 200 ) ); document->setTextWidth(200); QSize size = document->size().toSize(); size.setWidth(200); size.setHeight(200); editor->setDocument(document); //! [Inserting an image using HTML] editor->append("<img src=\"mydata://image.png\" />"); //------------------------------------------------------------------------------------- vbox->addWidget(editor); setLayout(vbox); }
QSizeF size(200, 200); document->setPageSize(size);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)