Results 1 to 7 of 7

Thread: Font size of a spinbox

  1. #1
    Join Date
    Mar 2008
    Posts
    57
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Font size of a spinbox

    I define the font size for all views/widgets in main. But I would like to set a different font size to a spinbox in one of the views. I do this explicitly like this

    Qt Code:
    1. pSpinbox = new QSpinBox(this);
    2. QFont font( pSpinbox->font() );
    3. font.setPointSize( 48 );
    4. pSpinbox->setFont( font );
    To copy to clipboard, switch view to plain text mode 

    But the font size of the spinbox remains the same? What is wrong?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Font size of a spinbox

    Could we see a larger portion of the code? Especially the main().

  3. #3
    Join Date
    Mar 2008
    Posts
    57
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Font size of a spinbox

    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication app(argc, argv);
    4.  
    5.  
    6.  
    7. return app.exec();
    8. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Font size of a spinbox

    Not really helpful. What's between lines 3 and 7?

  5. #5
    Join Date
    Mar 2008
    Posts
    57
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Font size of a spinbox

    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3.  
    4. QApplication app(argc, argv);
    5.  
    6. HmiMonitor *monitor = new HmiMonitor;
    7.  
    8. monitor->initiate();
    9.  
    10. return app.exec();
    11.  
    12. }
    13.  
    14. void HmiMonitor::initiate()
    15. {
    16.  
    17. KeyboardHandler *pKeyboard = new KeyboardHandler;
    18.  
    19. QPalette pal;
    20. pal.setColor(QPalette::Base, QColor(Qt::black));
    21. pal.setColor(QPalette::Window, QColor(Qt::black));
    22. pal.setColor(QPalette::Text, QColor(255, 230, 0));
    23. QApplication::setPalette(pal);
    24.  
    25. QApplication::setFont(QFont("Helvetica", 16));
    26.  
    27. SignalSubscriber *pSignalSubscriber = new SignalSubscriber;
    28.  
    29. CommandManager *pCommandManager = new CommandManager;
    30.  
    31. ViewManager *pViewManager = new ViewManager(
    32. pSignalSubscriber->getSignalManager(),
    33. pCommandManager);
    34.  
    35. }
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Font size of a spinbox

    So assuming that you apply the font to the spinbox in the constructor, you first change spinbox's font and then set the default font for the application overriding your earlier changes. Try doing it the other way round (contents of initialize() can be moved into the constructor).

  7. #7
    Join Date
    Mar 2008
    Posts
    57
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Font size of a spinbox

    I have tried your proposal, but it does not work. I should add that the code is executed on Qtopia in an embedded system. I suspect it has to do with Qtopia.

    I have done some prototyping on my laptop and there are no problems to change font size.

    I have talked to the company that provide the embedded target and Qtopia to check if there
    are some limits of the font sizes?

Similar Threads

  1. adjust Font size to a given rect when drawText
    By yartov in forum Qt Programming
    Replies: 5
    Last Post: 14th May 2008, 19:03
  2. Font size calculation when painting in a QImage
    By Ishark in forum Qt Programming
    Replies: 3
    Last Post: 15th July 2007, 22:22
  3. Replies: 3
    Last Post: 30th January 2007, 07:35
  4. QTreeView font size not being set
    By forrestfsu in forum Qt Tools
    Replies: 2
    Last Post: 12th October 2006, 13:53
  5. change font size and button size of QMessageBox
    By nass in forum Qt Programming
    Replies: 6
    Last Post: 13th September 2006, 19:16

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.