Results 1 to 2 of 2

Thread: Problem with setting font via stylesheet

  1. #1
    Join Date
    Jan 2006
    Location
    11 N 78 E
    Posts
    110
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Problem with setting font via stylesheet

    Hello. In my app I need to put three plain textboxes in three tabs. I'm trying to set the font of the textboxes via stylesheets but I seem to be doing something wrong -- can anyone help?

    I looked up the documentation and it said that for QTextEdits I should set the style for QAbstractScrollArea but still it is not working. I'm using a QPlainTextEdit -- is that a problem?

    The code is:

    Qt Code:
    1. # include <QtGui/QApplication>
    2. # include <QtGui/QPlainTextEdit>
    3. # include <QtGui/QTabWidget>
    4.  
    5. int main ( int argc, char * argv [] )
    6. {
    7. QApplication app ( argc, argv ) ;
    8. app . setStyleSheet ( "QAbstractScrollArea { font : \"DejaVu Sans\" }" ) ;
    9.  
    10. QPlainTextEdit * myInput = new QPlainTextEdit ;
    11.  
    12. QPlainTextEdit * stdOutput = new QPlainTextEdit ;
    13. stdOutput -> setReadOnly ( true ) ;
    14.  
    15. QPlainTextEdit * stdError = new QPlainTextEdit ;
    16. stdError -> setReadOnly ( true ) ;
    17.  
    18. QTabWidget * tabWidget = new QTabWidget ;
    19. tabWidget -> addTab ( myInput, "Input" ) ;
    20. tabWidget -> addTab ( stdOutput, "Output" ) ;
    21. tabWidget -> addTab ( stdError, "Errors" ) ;
    22.  
    23. tabWidget -> show () ;
    24. return app . exec () ;
    25. }
    To copy to clipboard, switch view to plain text mode 

    Any help is appreciated. Thanks.
    Penguin #395953 using Qt for open-source development on X11 using C++ and
    Python via PyQt

  2. #2
    Join Date
    May 2011
    Posts
    239
    Thanks
    4
    Thanked 35 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Symbian S60

    Default Re: Problem with setting font via stylesheet

    I don't know, but I think you should try setting the styleseet directly to the widget to see that it works, and after that try to get it inherited. There might just be something simple like a missing ; after the font name that makes Qt not understand the stylesheet.

Similar Threads

  1. Replies: 0
    Last Post: 12th August 2010, 16:05
  2. How to using/setting the font caching
    By iceman in forum Newbie
    Replies: 5
    Last Post: 28th July 2010, 05:35
  3. QCompleter once again (setting a font)
    By Lykurg in forum Qt Programming
    Replies: 2
    Last Post: 15th March 2007, 12:42
  4. Replies: 3
    Last Post: 30th January 2007, 07:35
  5. Reg - Font setting QListBox
    By lawrence in forum Newbie
    Replies: 1
    Last Post: 23rd December 2006, 20:07

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.