Skip to content
  • 0 Votes
    4 Posts
    386 Views
    J

    Oh.. I figured it out.
    That's just a simple unit conversion error.

    I used millimeter instead of pixel...

    >>> # Python >>> __editor.mmMarginLeft() 20 >>> __editor.pxMarginLeft() 110 >>> __editor.mmMarginLeft() == __editor.pxMarginLeft() False

    Now it's solved! THANKS a lot!
    Screenshot 2022-11-27 at 4.29.45 PM.png

  • 0 Votes
    2 Posts
    357 Views
    SGaistS

    Hi,

    Please provide a minimal compilable example to reproduce your issue.

  • 0 Votes
    2 Posts
    482 Views
    A

    Update
    Using format.setWidth(10);or doing format.setHeight(1000); has no effect on the cells visible height and width

  • 0 Votes
    3 Posts
    2k Views
    X

    Hi Henrik,

    as you requested by chat this is a more deep example.

    #ifndef MAINWIDGET_H #define MAINWIDGET_H #include <QWidget> class QResizeEvent; class QTextTable; class MainWidget : public QWidget { Q_OBJECT public: MainWidget(QWidget *parent = 0); ~MainWidget(); protected: void resizeEvent(QResizeEvent *event) override; public slots: void contextMenuRequested(const QPoint& pos); void showColorPicker(); private: QTextTable *_table; }; #endif // MAINWIDGET_H #include "MainWidget.h" #include <QTextEdit> #include <QTextCursor> #include <QTextTable> #include <QMenu> #include <QAction> #include <QColorDialog> #include <QDebug> MainWidget::MainWidget(QWidget *parent) : QWidget(parent) { setContextMenuPolicy(Qt::CustomContextMenu); connect(this, &QWidget::customContextMenuRequested,this, &MainWidget::contextMenuRequested); } MainWidget::~MainWidget() { } void MainWidget::contextMenuRequested(const QPoint& pos) { qDebug() << "Menu Requested"; QMenu *contextMenu = new QMenu(this); QAction *action = contextMenu->addAction("Color"); contextMenu->popup(mapToGlobal(pos)); connect(action, &QAction::triggered, this, &MainWidget::showColorPicker); } void MainWidget::resizeEvent(QResizeEvent *event) { QTextEdit *te = new QTextEdit(this); QTextCursor cursor = te->textCursor(); QTextTableFormat tf; tf.setBorderBrush(Qt::red); _table = cursor.insertTable(5, 5, tf); } void MainWidget::showColorPicker() { QColor color = QColorDialog::getColor(); QTextTableFormat tf = _table->format(); tf.setBorderBrush(color); _table->setFormat(tf); }

    Maybe you could change the QTextDocument style, to change all the tables in the document, this is somenthing I don't know.

    Hope this helps!

  • 0 Votes
    9 Posts
    5k Views
    C

    @mrjj As you said this isn't beginner stuff, have tried but can't get it to work properly so I'll leave it for now and return to it after some while. Thank you so much, really appreciate all the help!

  • 0 Votes
    1 Posts
    1k Views
    No one has replied