PDA

View Full Version : QTextEdit zoomIn() and zoomOut() appear to do nothing. What am I doing wrong?



dave
25th August 2010, 23:01
I can't really find any example how to use these functions. I though it was a simple matter of calling them, but it appears to have no effect on the widget. The whole idea of calling them manually was after I found out that ctrl+mouse wheel didn't zoom in/out the text as claimed in Qt help. So I made a QAction to do that instead. I can see the functions get called but nothing happens.

Thanks
Dave

Lykurg
25th August 2010, 23:29
int main(int argc, char *argv[])
{
QApplication app(argc, argv);

QTextEdit e;
e.setText("test foo bar");
e.showMaximized();

QTimer t;
t.setInterval(150);
QObject::connect(&t, SIGNAL(timeout()), &e, SLOT(zoomIn()));
t.start();

return app.exec();
}

Works for me. If it also works for you, then your code has some errors and you have to show us how you do it.

dave
26th August 2010, 02:35
Well, your code worked for me too :). So I tried to narrow down why mine didn't. The following code exhibit the same symptoms as my code (at least on my machine). I still have no idea what am I doing wrong.




#include <QApplication>
#include <QTextEdit>
#include <QTimer>
#include <QFont>


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

QApplication app(argc, argv);

QTextEdit e;

QFont f("Arial", 14);

e.setCurrentFont(f);

e.setText("test foo bar");

e.showMaximized();


QTimer t;

t.setInterval(150);

QObject::connect(&t, SIGNAL(timeout()), &e, SLOT(zoomIn()));

t.start();

return app.exec();
}

Lykurg
26th August 2010, 08:46
You have to use setFont(). Then it works. setCurrentFont adds a "permanent" font.