PDA

View Full Version : how can i make QTextTable frame color be white ?



tinysoft
14th April 2011, 17:00
hi every one

how can i make the QTextTable frame in QTextEdit be white so that i won't appear at printing ?

i tried this one but it still shown :


#include <QApplication>
#include <QTextEdit>
#include <QTextTableCell>



int main(int argc,char* argv[])
{
QApplication app(argc,argv);

QStringList list;
list<<"ID";

QTextCharFormat cellFormat;
cellFormat.setBackground(QColor(Qt::white));

QVector<QTextLength> constraints;
constraints<<QTextLength(QTextLength::PercentageLength,50);
constraints<<QTextLength(QTextLength::PercentageLength,50);



QTextEdit* textEdit=new QTextEdit;
textEdit->setReadOnly(true);

QTextCursor cursor=textEdit->textCursor();

QTextCharFormat boldFormat;
boldFormat.setFontWeight(QFont::Bold);

QTextTableFormat tableFormat;
tableFormat.setBackground(QColor(Qt::white));
tableFormat.setAlignment(Qt::AlignHCenter);
tableFormat.setColumnWidthConstraints(constraints) ;
tableFormat.setCellPadding(40);



cursor.insertText("table below ");
QTextTable* table=cursor.insertTable(1,2,tableFormat);


for(int j=0;j<1;j++)
{
QTextTableCell cell=table->cellAt(0,j);
cell.setFormat(cellFormat);
cursor=cell.firstCursorPosition();
cursor.insertText(list[j],boldFormat);
}



textEdit->show();
return app.exec();
}


i want it to be:

from this :
http://www.mediafire.com/imgbnc.php/8b9694b9ebf5d41a8baebc530ac9fefd59b9f67c0e86fc883d a3a4916d9d0aeb6g.jpg

to this shape :
http://www.mediafire.com/imgbnc.php/0609438e331ee86c9f64da3c9051517dde4d69787be2ff1ae9 470f2ec308cee66g.jpg

any ideas ??

tinysoft
15th April 2011, 16:18
Problem solved!

i added this line after its declare :


tableFormat.setBorder(0);

and .... Done!:D