Results 1 to 4 of 4

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

  1. #1
    Join Date
    Jan 2006
    Posts
    52
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTextEdit zoomIn() and zoomOut() appear to do nothing. What am I doing wrong?

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QTextEdit zoomIn() and zoomOut() appear to do nothing. What am I doing wrong?

    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication app(argc, argv);
    4.  
    5. e.setText("test foo bar");
    6. e.showMaximized();
    7.  
    8. QTimer t;
    9. t.setInterval(150);
    10. QObject::connect(&t, SIGNAL(timeout()), &e, SLOT(zoomIn()));
    11. t.start();
    12.  
    13. return app.exec();
    14. }
    To copy to clipboard, switch view to plain text mode 

    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.

  3. #3
    Join Date
    Jan 2006
    Posts
    52
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTextEdit zoomIn() and zoomOut() appear to do nothing. What am I doing wrong?

    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.


    Qt Code:
    1. #include <QApplication>
    2. #include <QTextEdit>
    3. #include <QTimer>
    4. #include <QFont>
    5.  
    6.  
    7. int main(int argc, char *argv[])
    8. {
    9.  
    10. QApplication app(argc, argv);
    11.  
    12.  
    13. QFont f("Arial", 14);
    14.  
    15. e.setCurrentFont(f);
    16.  
    17. e.setText("test foo bar");
    18.  
    19. e.showMaximized();
    20.  
    21.  
    22. QTimer t;
    23.  
    24. t.setInterval(150);
    25.  
    26. QObject::connect(&t, SIGNAL(timeout()), &e, SLOT(zoomIn()));
    27.  
    28. t.start();
    29.  
    30. return app.exec();
    31. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QTextEdit zoomIn() and zoomOut() appear to do nothing. What am I doing wrong?

    You have to use setFont(). Then it works. setCurrentFont adds a "permanent" font.

  5. The following user says thank you to Lykurg for this useful post:

    dave (26th August 2010)

Similar Threads

  1. ZoomIn QGraphicsItem
    By xlttap in forum Qt Programming
    Replies: 1
    Last Post: 29th October 2009, 11:32
  2. Replies: 1
    Last Post: 5th March 2009, 05:52
  3. zoomin/zoomout
    By bhogasena in forum Qt Programming
    Replies: 1
    Last Post: 23rd January 2009, 15:18
  4. Replies: 2
    Last Post: 13th January 2009, 04:32
  5. QTextEdit wrong color
    By thomaspu in forum Qt Programming
    Replies: 3
    Last Post: 18th January 2008, 04:35

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.