Planned maintenance: From Sunday 8th December 10:00 CET there will be changes to try and solve the caching issues that have been experienced. If anyone has a problem connecting after this period then please PM @AndyS or any of the moderators.

two combo boxes next to each other



  • i wanna implement two combo boxes next to each other (in horizontal layout) but will little or luck. but they appear in vertical anyways. here's what i've tried:

    auto fontFamilyComboBox = new QFontComboBox(this);
    QWidgetAction *action = new QWidgetAction(this);
    fontFamilyComboBox->setDefaultAction(action);
    // code to add fontFamilyComboBox to where it belongs
    
    auto fontSizeComboBox = new QComboBox(this);
    fontSizeComboBox->setMaximumWidth(50);
    // code to add items to this combo box
    // code to add fontSizeComboBox to where it belongs
    
    QHBoxLayout *fontLayout = new QHBoxLayout(this);
    fontLayout->addWidget(fontFamilyComboBox);
    fontLayout->addWidget(fontSizeComboBox);
    setLayout(fontLayout);
    

    i've also tried QGridLayout but that didn't show the second combo box entirely.



  • @user4592357 said in two combo boxes next to each other:

    QHBoxLayout *fontLayout = new QHBoxLayout(this);

    Hi @user4592357

    in this line

    QHBoxLayout *fontLayout = new QHBoxLayout(this);
    

    this must refer to the parent widget in which you want add your layout

    Can you share more source code ?



  • that's what i was missing. thanks!



  • @user4592357 said in two combo boxes next to each other:

    that's what i was missing. thanks!

    You're welcome =)


Log in to reply