Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

how to make text size auto scale with size of window as window size changes



  • Hi, I had seen a YouTube video in which I think only layouts were used and then the text inside of widgets changed sizes as the widgets changed sizes. But now I can't find it and everything I have read since says there is no automatic way to do this and so code is needed to manually change font sizes. Is there a way to scale fonts automatically ? If not, my new question is this. Is there a way to change the font of 25 buttons with one line of code as in something like Button 1-20 font size = X, or do I need to do it with 20 lines of code ?


  • Lifetime Qt Champion

    Hi,

    One way to do it is to create a custom QPushButton and reimplement its resizeEvent. In there you can calculate the size you want for your font and apply it.



  • Thank you


Log in to reply