i have a Qt code writed in C++ . i want translate it to python code
-
QTextDocument *doc = new QTextDocument;
doc->setDocumentMargin(10);
QTextCursor cursor(doc);cursor.movePosition(QTextCursor::Start);
QTextTable *table = cursor.insertTable(properties.size() + 1, 2, tableFormat);
QTextTableCell headerCell = table->cellAt(0, 0);
QTextCursor headerCellCursor = headerCell.firstCursorPosition();
headerCellCursor.insertText(QObject::tr("Name"), boldFormat);
headerCell = table->cellAt(0, 1);
headerCellCursor = headerCell.firstCursorPosition();
headerCellCursor.insertText(QObject::tr("Value"), boldFormat);for(int i = 0; i < properties.size(); i++){
QTextCharFormat cellFormat = i % 2 == 0 ? textFormat : alternateCellFormat;
QTextTableCell cell = table->cellAt(i + 1, 0);
cell.setFormat(cellFormat);
QTextCursor cellCursor = cell.firstCursorPosition();
cellCursor.insertText(properties.at(i)->name());cell = table->cellAt(i + 1, 1); cell.setFormat(cellFormat); cellCursor = cell.firstCursorPosition(); cellCursor.insertText(properties.at(i)->value().toString() + " " + properties.at(i)->unit());
}
cursor.movePosition(QTextCursor::End);
cursor.insertBlock(); -
Have you even tried rewriting this yourself in python / qt (of whatever style and flavor you plan on using which you did not state by the way) -- if no then frankly why should we?
So as an assignment back to you -- we have your Qt? (5) C++ code please show us how you think it might be rendered in your Python version ?? and Qt (style and version ??) then perhaps we can help you refine that. Expecting us to do all your work is a bit presumptuous. Note in my experience most folks would just simply ignore this request while I am trying to actually help you understand what might be wrong with this request and help you build a better request that will get you a response
-
i need to export data from Qtablewidget to pdf version i found code writed in c++ and i want to translate it to python code !!?
-
Awesome sounds like an excellent endeavor keep in mind that python is a C based language and so is C++ granted their syntax is different but for the most part you should be able to analyze what you have in C++ and port that to python -- now sure you might run into a few issues and that is where we come in to help you with those specific issues not do all the work for you for free.
So how do YOU think the C++ code should look if you rendered it in Python?
Oh and I take it English (or Anglish ... American english) is not your native language as "writed" should be "written" instead no judgement just trying to help with that as well.
So once you have some kind of python version of the above or a specific question about a specific piece (and do not just create a series of questions starting from the first line and going down - you will not learn if you do not try and I will almost guarantee you that this will not be your only walk down this path). Especially since all python Qt is ultimately based off of the C++ oriented Qt
For instance that first line ought to be easy doc = QTextDocument() that is the python version of the C++ command as you are simply initializing the "doc" variable to the QTextDocument class object. Happy translating.
-
Merci pour votre conseil , le problème c'est que j'ai lu tout ce texte mais tellement sans bénéfice ,et le plus important pour moi en ce moment c'est avoir une réponse compatible avec la question, joueuse translation
-
@Bouslama-reda It is actually not hard to translate to Python. Qt is the same you just need to rewrite this code using Python syntax. So please try and tell us what is not working.