[SOLVED] combobox font question



  • font question:
    in the gui builder, i have selected a size 14 font for the combobox. when i build the app, the size 14 font is not displayed in the combobox. instead, the combobox is displaying the default font. when i select an item from the drop down box, all the items are displayed in a size 14 font. yet once selected, it displays the result of the item back in the default font. how do i solve this issue?

    menu question: deleted



  • Please keep the combobox context menu questions in your "old thread":http://developer.qt.nokia.com/forums/viewthread/10887/ - it does not help to ask it multiple times.

    Regarding the font:
    It seems that this is only saved correctly if you set the font on the combo box while it is not set to editable. So in Designer, the steps that worked for me are:

    • set the combo box to editable disabled
    • select and set the desired font
    • make the combo box editable again (if needed)

    I checked the font using Designer's preview function.



  • the font is still not working for me. perhaps i am doing something wrong. in the qt builder, i set the combobox font to 14 and then clicked the "editable" to false.

    the code has the following in it...
    @ui->userName->setFont(QFont ("Courier New", 14));
    ui->userName->setEditable(true);
    ui->userName->setFont(QFont ("Courier New", 14));@

    still the font is not changing.

    Volker, i don't understand when you say that you checked the font using the designers preview function?



  • i solved the combobox font problem in editable mode by using the following style code :)

    @ QComboBox {
    font-family: "Verdana";
    font-size: 11pt;
    }@



  • [quote author="kalster" date="1319326678"]
    Volker, i don't understand when you say that you checked the font using the designers preview function?[/quote]

    I meant that I used Qt Designer to create the UI and to change the font. Designer also has a preview mode (Ctrl-R) where you can check the settings.

    I just checked on a Mac machine, setting the font using C++ like in your first attempt works for me. What OS do you use?



  • windows



  • I'm at the Developer Days right now, I'll have a look on my Windows box once I'm at home again.



  • Hi,

    I checked on windows (ok, using code :-)) and it works perfectly:

    @
    QComboBox* pCbo = new QComboBox;
    QFont ft("Courier New", 14);
    pCbo->setEditable(true);
    pCbo->setFont(ft);

    pCbo->addItem("Item 1");
    pCbo->addItem("Item 2");
    pCbo->addItem("Item 3");
    pCbo->addItem("Item 4");
    pCbo->addItem("Item 5");
    pCbo->addItem("Item 6");
    

    @



  • that's strange Gerolf, its still not working for me. i am using vista. but that's ok, because i am using a style sheet and that works good.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.