Qtextbrowser and using rendering



  • hello
    im an entry level programmer and new to QT also so im still getting my way around this stuff. I have a program where i am trying to print a pdf and in this pdf i wanna show a table and image graph or render a graph to be exact. so far i get my text table but my image wont show and it only shows one page. So far i have tried QpaintEditor and QImagetext, being i might have not set them up properly so and help would be amazing.

    so this is how i set up my pdf and how i set up the table that works you can see my attempt to use QImageText

    @void MainWindow::QTableWidget2QTextBrowser(QTableWidget *tabW,QTextBrowser *editor)
    {
    ///creates writing format
    QTextCharFormat NormalFormat;
    editor->setCurrentCharFormat(NormalFormat);

    //create pointer to current cursor location
    QTextCursor cursor =editor->textCursor();
    cursor.beginEditBlock();
    
    QTextTableFormat tableFormat;
    tableFormat.setAlignment(Qt::AlignLeft);
    tableFormat.setBackground(QColor("#ffffff"));
    tableFormat.setCellPadding(3);
    tableFormat.setCellSpacing(3);
    
    QTextTable *tab=cursor.insertTable(tabW->rowCount()+1,tabW->columnCount(),tableFormat);
    QTextFrame *frame=cursor.currentFrame();
    QTextFrameFormat frameFormat=frame->frameFormat();
    frameFormat.setBorder(0);
    frame->setFrameFormat(frameFormat);
    
    QTextCharFormat format_entete_tab;
    format_entete_tab.setFontPointSize(12);
    format_entete_tab.setFontWeight(QFont::Bold);
    
    QTextCharFormat format_cellule;
    format_cellule.setFontPointSize(11);
    
    for(int i=0;i<tabW->columnCount();i++)
    {
        QTextTableCell titre = tab->cellAt(0,i);
        QTextCursor cellCursor=titre.firstCursorPosition();
        cellCursor.insertText(tabW->horizontalHeaderItem(i)->text(),format_entete_tab);
    }
    QTextTableCell cell;
    QTextCursor cellCursor;
    for(int row=1;row<tab->rows();row++)
    {
        for(int col=0;col<tab->columns();col++)
        {
            cell=tab->cellAt(row,col);
            cellCursor=cell.firstCursorPosition();
            cellCursor.insertText(tr("%1").arg(tabW->item(row-1,col)->text()),format_cellule);
        }
    }
    cursor.endEditBlock();
    

    }@

    This is the problem
    @// // Print Graph

    //// QwtPlotRenderer renderer;
    //// renderer.setDiscardFlag(QwtPlotRenderer::DiscardBackground,false);
    //// renderer.setLayoutFlag(QwtPlotRenderer::KeepFrames,true);
    //// renderer.render(m_plot,&painter,QRect(0,printer->height()/2,printer->width(),printer->height()/2.2));
    //// printer->newPage();
    @

    and this is how i set up my my QtextBrowser if there is an error here to in my setup please say so i need to learn.
    @void MainWindow::QTableWidget2QTextBrowser(QTableWidget *tabW,QTextBrowser *editor)
    {
    ///creates writing format
    QTextCharFormat NormalFormat;
    editor->setCurrentCharFormat(NormalFormat);

    //create pointer to current cursor location
    QTextCursor cursor =editor->textCursor();
    cursor.beginEditBlock();
    
    QTextTableFormat tableFormat;
    tableFormat.setAlignment(Qt::AlignLeft);
    tableFormat.setBackground(QColor("#ffffff"));
    tableFormat.setCellPadding(3);
    tableFormat.setCellSpacing(3);
    
    QTextTable *tab=cursor.insertTable(tabW->rowCount()+1,tabW->columnCount(),tableFormat);
    QTextFrame *frame=cursor.currentFrame();
    QTextFrameFormat frameFormat=frame->frameFormat();
    frameFormat.setBorder(0);
    frame->setFrameFormat(frameFormat);
    
    QTextCharFormat format_entete_tab;
    format_entete_tab.setFontPointSize(12);
    format_entete_tab.setFontWeight(QFont::Bold);
    
    QTextCharFormat format_cellule;
    format_cellule.setFontPointSize(11);
    
    for(int i=0;i<tabW->columnCount();i++)
    {
        QTextTableCell titre = tab->cellAt(0,i);
        QTextCursor cellCursor=titre.firstCursorPosition();
        cellCursor.insertText(tabW->horizontalHeaderItem(i)->text(),format_entete_tab);
    }
    QTextTableCell cell;
    QTextCursor cellCursor;
    for(int row=1;row<tab->rows();row++)
    {
        for(int col=0;col<tab->columns();col++)
        {
            cell=tab->cellAt(row,col);
            cellCursor=cell.firstCursorPosition();
            cellCursor.insertText(tr("%1").arg(tabW->item(row-1,col)->text()),format_cellule);
        }
    }
    cursor.endEditBlock();
    

    }@


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.