maartenS
20th September 2008, 14:05
Hi,
I'm trying to resize a QTextEdit to make it possible to zoom in and out.
I'm not satisfied with the result and I'm wondering if I should do it this way.
This is what I did:
textArea = new KTextEdit;
textArea->setMinimumSize(256,384);
textArea->resize(400,600);
scrollArea = new QScrollArea;
scrollArea->setWidget(textArea);
scrollArea->setBackgroundRole(QPalette::Dark);
scrollArea->setAutoFillBackground(true);
setCentralWidget(scrollArea);
and now resizing gives wrong sizes.
void MainWindow::zoomOut()
{
qDebug() << "zoomOut before:" << textArea->viewport()->size(); // is ok
qDebug() << (0.8 * textArea->viewport()->size()); //is ok
textArea->resize(0.8 * textArea->viewport()->size());
qDebug() << "zoomOut after:" << textArea->viewport()->size(); // 6 points to small??
}
void MainWindow::zoomIn()
{
qDebug() << "zoomIn before:" << textArea->viewport()->size(); //is ok
qDebug() << (1.25 * textArea->viewport()->size()); //is ok
textArea->resize(1.25 * textArea->viewport()->size());
qDebug() << "zoomIn after:" << textArea->viewport()->size(); //6 points to small??
}
1. After every resize there are 6 points lost, and I don't know where they've gone.
Any ideas?
2. Is it possible to put the QTextEdit widget in the middle of the QScrollArea.
3. The background of the scrollbars is the background set with
scrollArea->setBackgroundRole(QPalette::Dark);
I would like to integrate it better with the mainwindow.
In the QT tutorials there is an example (viewimage) that uses a QLabel for this. Is this a better way to zoom a widget? I need to make a QTextDocument and I want to display tables and I couldn't find a possibility for this with QLabel.
I have the feeling I'm on the wrong track. Can someone help me a bit further? Thanks!
I'm trying to resize a QTextEdit to make it possible to zoom in and out.
I'm not satisfied with the result and I'm wondering if I should do it this way.
This is what I did:
textArea = new KTextEdit;
textArea->setMinimumSize(256,384);
textArea->resize(400,600);
scrollArea = new QScrollArea;
scrollArea->setWidget(textArea);
scrollArea->setBackgroundRole(QPalette::Dark);
scrollArea->setAutoFillBackground(true);
setCentralWidget(scrollArea);
and now resizing gives wrong sizes.
void MainWindow::zoomOut()
{
qDebug() << "zoomOut before:" << textArea->viewport()->size(); // is ok
qDebug() << (0.8 * textArea->viewport()->size()); //is ok
textArea->resize(0.8 * textArea->viewport()->size());
qDebug() << "zoomOut after:" << textArea->viewport()->size(); // 6 points to small??
}
void MainWindow::zoomIn()
{
qDebug() << "zoomIn before:" << textArea->viewport()->size(); //is ok
qDebug() << (1.25 * textArea->viewport()->size()); //is ok
textArea->resize(1.25 * textArea->viewport()->size());
qDebug() << "zoomIn after:" << textArea->viewport()->size(); //6 points to small??
}
1. After every resize there are 6 points lost, and I don't know where they've gone.
Any ideas?
2. Is it possible to put the QTextEdit widget in the middle of the QScrollArea.
3. The background of the scrollbars is the background set with
scrollArea->setBackgroundRole(QPalette::Dark);
I would like to integrate it better with the mainwindow.
In the QT tutorials there is an example (viewimage) that uses a QLabel for this. Is this a better way to zoom a widget? I need to make a QTextDocument and I want to display tables and I couldn't find a possibility for this with QLabel.
I have the feeling I'm on the wrong track. Can someone help me a bit further? Thanks!