Skip to content
  • Custom ComboBox not scrolling

    Unsolved QML and Qt Quick combobox scroll
    2
    0 Votes
    2 Posts
    192 Views
    S
    It seems the issue you're experiencing with the ComboBox not scrolling when there are many items is due to the absence of proper height configuration for the ListView inside the Popup. The ListView needs an explicit height to trigger scrolling behavior, and without it, the dropdown won't scroll even when there are many items. To fix this, you can add a fixed or constrained height to the ListView, and ensure the ScrollIndicator appears when needed. Here's the updated code for the popup section: popup: Popup { y: control.height - 1 width: control.width implicitHeight: contentItem.implicitHeight padding: 0 contentItem: ListView { width: parent.width height: Math.min(200, contentHeight) // Constrain the ListView height or set a max height clip: true model: control.popup.visible ? control.delegateModel : null currentIndex: control.highlightedIndex ScrollIndicator.vertical: ScrollIndicator { visible: contentHeight > height // Only show the scroll indicator if the content exceeds the viewable area } } background: Rectangle { radius: 0 color: Qt.color(AppTheme.colors["UFO_ComboBox_Popup_Background"]) border.color: Qt.color(AppTheme.colors["UFO_ComboBox_DropBox_Border"]) } }
  • 0 Votes
    3 Posts
    358 Views
    D
    @Christian-Ehrlicher Hi, I have not manually set any css styling the colours I belive just come from fact I am using ubuntu so I think its just using system colours by default
  • How to set QStyle::SH_ComboBox_Popup to false?

    Unsolved General and Desktop qstyle combobox fusion
    6
    0 Votes
    6 Posts
    1k Views
    CJhaC
    @raven-worx For me, it seems as it is working. The above code is actually taken from ProxyStyle web page from Qt's website, I just replaced QStyle::SH_UnderlineShortcut with QStyle::SH_ComboBox_Popup. So, I think it is a good approach. Subclassing QComboBox would become quite cumbersome as I will have to promote all the combo boxes in my UI to the subclass.
  • QComboBox and smart pointer conflict?

    Unsolved General and Desktop combobox smart pointers exception
    9
    0 Votes
    9 Posts
    904 Views
    S
    @CJha said in QComboBox and smart pointer conflict?: But in any case I would like to make sure that it is destroyed before the application exits. In general this is a good approach. When you write clean code all resources should be freed by your own application (typically RAII in C++). However, when your application closes the OS will free all memory belonging to the application and removes all file handles of the application. Especially in complex applications it can take quite a while to clean up everything in order. In those cases it is a lot more userfriendly to just exit without the clean up. So, don't worry too much about clean up. Still, you should understand why this happens and how it can be avoided.
  • Combo Box problem in QGIS

    Unsolved Qt Creator and other tools qt designer qgis combobox
    2
    0 Votes
    2 Posts
    468 Views
    SGaistS
    Hi and welcome to devnet, Without a minimal code example showing what you do it's not possible to see what might be wrong.
  • read value from combo box to c++ function

    Unsolved QML and Qt Quick qml c++ combobox signal signal & slot
    5
    0 Votes
    5 Posts
    1k Views
    GrecKoG
    @texasRanger said in read value from combo box to c++ function: I have been trying to connect the qml signal of the combo box being changed to the itemChanged slot in c++. but I have had no luck. Don't do that. Do like in the link posted by SGaist. Some links about the reason why you shouldn't reach into QML from C++: https://doc.qt.io/qt-5/qtquick-bestpractices.html#interacting-with-qml-from-c http://doc.qt.io/qt-5/qtqml-cppintegration-overview.html#interacting-with-qml-objects-from-c https://youtu.be/vzs5VPTf4QQ?t=23m20s
  • 0 Votes
    5 Posts
    1k Views
    fcarneyF
    If you use the the same model instance in more than one place they will always have the same index. This may, or may not be what you want. FYI
  • 0 Votes
    3 Posts
    5k Views
    A
    @nagesh No style sheet, however, I had experiemented with the stylesheet in the link that you sent, and I couldn't figure it out. Which fields pertain to the width of the drop-down? There is a horizontal layout, however, I have also tried without layout and I get the same issue. I can control the width of the Combobox when it is closed, but once open there is an offset, that is what I would like to remove. Thank you, Arjun
  • Open the selected port

    Unsolved General and Desktop serial port qt5 combobox
    5
    0 Votes
    5 Posts
    820 Views
    Pablo J. RoginaP
    @suslucoder said in Open the selected port: I solved it, you can delete my post. No, the solved posts don't get deleted. They remain for the benefit of other forum users having same/similar issues. It's a community driven approach, opposite to a "my problem only" driven approach
  • Open the port which selected on combo box

    Unsolved General and Desktop combobox serial port qt5
    10
    0 Votes
    10 Posts
    2k Views
    jsulmJ
    @suslucoder I don't see why it would not be possible to select other entries in a combo box. Do you do anything else with ui->ports?
  • Using editable ComboBox

    Solved QML and Qt Quick editablcombobox combobox
    4
    0 Votes
    4 Posts
    1k Views
    K
    Thought initially that the issue could be completely solved in qml, but Settings seem to miss some features as present in QSettings. Therefore decided to move forward with solution based on C++ with QML. https://forum.qt.io/topic/120954/combobox-together-with-qstringlistmodel
  • 0 Votes
    5 Posts
    2k Views
    C
    @JonB alright.I will remember that
  • why show Popup function of comboBox is not working?

    Unsolved General and Desktop combobox
    2
    0 Votes
    2 Posts
    433 Views
    B
    count() just return the number of items as the result, what do you expect it to work? showPopup() should be called on the combo box, so ui->comboBox->showPopup(). Are you also new to C++? Feels like you need learn some basics first.
  • 0 Votes
    4 Posts
    656 Views
    SGaistS
    Your BluetoothController should have a member variable of the BluetoothModel class. Your BluetoothModel class should provide an API that your BluetoothController can connect to and also that provides whatever data is needed.
  • 0 Votes
    2 Posts
    709 Views
    B
    Update: I downloaded the most recent version of Qt, 5.13.0, and I could not get the issue to repeat. So I think the problem is related to specific versions of Qt.
  • PlaceHolder in ComboBox

    Solved QML and Qt Quick combobox placeholder
    2
    0 Votes
    2 Posts
    1k Views
    G
    I figured it out: displayText: currentIndex === -1 ? "Choose ..." : currentIndex
  • 0 Votes
    2 Posts
    1k Views
    S
    Ok, I have figured it out by myself. The key was looking at the comboBoxModel->data and getting the index from rows and coloumns. That's my solution: void comboBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { if(QComboBox *cb = qobject_cast<QComboBox*>(editor)) { QString cbText = cb->currentText(); int vpe_index = -1; for (int row = 0; row < comboBoxModel->rowCount() ; row++) { if (comboBoxModel->data(comboBoxModel->index(row, 0)) == cbText){ vpe_index = comboBoxModel->data(comboBoxModel->index(row, 1)).toInt(); } } if (vpe_index == -1) { qDebug() << "Index not found"; } else { qDebug() << "Index set: " << model->setData(index, vpe_index, Qt::EditRole); } } else { QStyledItemDelegate::setModelData(editor, model, index); } }
  • 0 Votes
    9 Posts
    10k Views
    J.HilkJ
    @koahnig said in changing combobox index when selection of another combobox is changed: Probably a really stupid question: Why do I need "===" and not "==" ? Because you want to be really really sure that they are equal x) No, JavaScript does conversion checks as well "1" == 1 -> true "1" === 1 -> false And I love C++!!! hear,hear!
  • 0 Votes
    4 Posts
    787 Views
    Christian EhrlicherC
    I said 'Maybe you've a typo...' The problem with auto-connect is that you can not be sure if it is really connected (e.g. when there is a typo somewhere in the functions signature or the ui element name) and it easily breaks (e.g. when renaming an ui element).