I created a table of 5 cell and set width of each to 50.

QVector<QTextLength> columnWidth;
const QVector<int> width = { 50,50,50,50,50};

for(int i = 0; i < width.size(); ++i)
columnWidth.append(QTextLength(QTextLength::FixedL ength, width[i]));

QTextTableFormat *tableFormat = new QTextTableFormat();
QTextTable* newTable=cursor.insertTable(1, 5, *tableFormat);

In the QTextEdit view everything looks normal and the table looks like:

However after saving and reopening the html, it becomes:

Checking on the HTML code it generates, looks like the width for the merged cell is not set. What should I do?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>QTextEdit Example</title><style type="text/css">p, li { white-space: pre-wrap; }</style></head>
<body style=" font-family:'Arial'; font-size:11pt; font-weight:400; font-style:normal;">
<table border="1" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px;" cellspacing="2" cellpadding="0">
<td width="50"></td>
<td colspan="2"></td>
<td width="50"></td>
<td width="50"></td></tr></table></body></html>