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

QFontCombox not returning the font family



  • How do I make QFontComboBox to return a list of font family only but not the complete dialog pop-up with font style, point size and other style techniques(kerning, strikeout,underline). I'm doing something like this:

    QFont Vizkit3DWidget::getFont()const                                                          
    { 
               QFontComboBox *dialog = new QFontComboBox();
               QFont font=dialog->currentFont();
               return font.family(),
        
    }
    
    void Vizkit3DWidget::setFont(QFont font)
    {
               QFontComboBox *dialog = new QFontComboBox();
               dialog->setCurrentFont(font);
    }
    

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    If you want a list of the font families then why not just use QFontDatabase::families ?



  • @SGaist How do I set Kerning(),Strikeout,Underline() to disable in the above code since they are always called after the QFontComboBox constructor and even if set to disable, dialogbox still shows them.



  • @SGaist Actually I'm trying to set the selected QFont onto an osg::text3D node, setFont(), SetStyle(),SetCharactersize() ->extracting each of these seperatle from QFont applying them on text3D.


  • Lifetime Qt Champion

    The code you show above does not much.

    You should explain exactly what you are trying to achieve because you are talking about a dialog yet create a combo box that you don't even show.


  • Banned

    Even better supply a MRE (Minimal Reproducible Example) that we can just copy/paste and run as that will greatly speed up our ability do you a favor and help you with your issue


Log in to reply