PDA

View Full Version : Need help, i want know how i mus do to see in main window piece of paper



Arcimedes
10th May 2017, 14:06
Need help, i want know how i mus do to see in main window piece of paper like in office word

d_stranz
10th May 2017, 17:58
It is hard to understand what you are asking. Microsoft Office does not display "paper", it displays the formatted contents of documents. Maybe the Text Edit example (https://doc.qt.io/qt-5/qtwidgets-richtext-textedit-example.html) from the Qt distribution might give you some help. If you want to display the image of a page you have scanned into your computer, then the Image Viewer (https://doc.qt.io/qt-5/qtwidgets-widgets-imageviewer-example.html) example might be helpful.

Santosh Reddy
11th May 2017, 05:54
If it is a matter of one single paper (as you call it so), put the paper widget in a layout and set the layout margins accordingly.

Arcimedes
15th May 2017, 08:53
I would like it to look exactly like in the microsoft word
when the end of the card and the other is starting, I do not know how to write such leyout with margins

Santosh Reddy
30th June 2017, 08:55
Here is an example
12508


#include <QtWidgets>

class PageLayout : public QWidget
{
public:
explicit PageLayout(QWidget * parent = 0)
: QWidget(parent)
, mLayout(new QGridLayout(this))
{
QPalette pal = palette();
pal.setColor(QPalette::Background, Qt::darkGray);
setPalette(pal);
setAutoFillBackground(true);
mLayout->setMargin(20);
mLayout->setSpacing(20);
}

void addPage(QWidget * page)
{
page->setAutoFillBackground(true);
page->setFixedSize(QSize(100, 100));
mLayout->rowCount();
mLayout->addWidget(page, mLayout->rowCount() + 1, 0, 1, 1, Qt::AlignCenter);
}

private:
QGridLayout * const mLayout;
};

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

PageLayout layout;
layout.addPage(new QLabel("Page 1"));
layout.addPage(new QLabel("Page 2"));
layout.addPage(new QLabel("Page 3"));
layout.addPage(new QLabel("Page 4"));
layout.show();

return a.exec();
}