Skip to content
QtWS25 Last Chance
  • Custom ComboBox not scrolling

    Unsolved QML and Qt Quick
    2
    0 Votes
    2 Posts
    130 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
    6 Posts
    1k Views
    SGaistS

    Don't you have access to the source code ?
    And if not, ask the authors ?

  • 0 Votes
    2 Posts
    819 Views
    A

    @jeanmilost
    Your logic seems to be correct.
    What you have to do is to move the re-calculation of Scrollbar size & position to the Rectangle rcPageContainer because you are applying scale for that.

    Rectangle { id: rcPageContainer objectName: "rcPageContainer" ... /// called when page viewport width changed onWidthChanged: { sbHorz.size = rcPageViewport.width / rcPageContainer.width sbHorz.position = Math.min(Math.max(sbHorz.position, 0.0), 1.0 - (sbHorz.size)); } /// called when page viewport height changed onHeightChanged: { sbVert.size = rcPageViewport.height / rcPageContainer.height sbVert.position = Math.min(Math.max(sbVert.position, 0.0), 1.0 - (sbVert.size)); } }
  • 0 Votes
    2 Posts
    968 Views
    jeanmilostJ

    Finally I searched a while by myself, and I think I may answer my own question. Although I couldn't completely resolve my issue, I noticed that the answer is hidden in the other MouseArea events. For example, by handling the onPressed event and adding the mouse.accepted in several key locations, I could let the component take care of the scrolling when the left mouse button is pressed, whereas the right click opens a popup menu.

    My conclusion is that there is no ready-to-use way, i.e there is no parameter to activate in the MouseArea itself which may resolve this kind of issue, and the solution is a good balance between activating different parameters in the different functions.

  • 0 Votes
    5 Posts
    7k Views
    T
    table->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); table->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents); setMinimumWidth(table->sizeHint().width());
  • Get scroll position of ScrollArea

    Unsolved QML and Qt Quick
    1
    0 Votes
    1 Posts
    760 Views
    No one has replied
  • 0 Votes
    1 Posts
    480 Views
    No one has replied
  • 0 Votes
    4 Posts
    2k Views
    J

    Yes, it returns NULL if the cast failed.

    As for the type, this might also work:

    QObject *obj = widget; objType = obj->metaObject()->className(); if (objType == "QPlainTextEdit") { QPlainTextEdit *textEdit = qobject_cast<QPlainTextEdit*>(obj); //do something }

    Never tried it though. If it works, you won't have to make multiple casts.
    But you will still have to check which className it has.

  • 0 Votes
    5 Posts
    2k Views
    McLionM

    Could not find anything.

  • 0 Votes
    5 Posts
    5k Views
    AmrCoderA

    I solve it I use the same thing

    ui->comboBox->view()->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);

    if there is a better solution please post it
    Thanks

  • 0 Votes
    3 Posts
    2k Views
    D

    @SGaist Thanks Champion! I will try !

  • 0 Votes
    3 Posts
    2k Views
    I

    @SGaist That's pretty close to what I like to achieve. Unfortunately I am using a QML TableView. The only difference to the FrozenColumnExample is that my Frozen Rows have a dynamic count. A binary role in my table model determines to which section the entry belongs to. I will try to adapt the FrozenColumnExample to my case in QML. That was my idea anyway, but I was hoping for more simple solution ;) Substituting the sections with seperate TableViews and using a QSortFilterProxyModel to simulate the section behavior is the way to go I guess. Thx for your tip.

  • 0 Votes
    2 Posts
    5k Views
    mrjjM

    Hi and welcome
    I think you might need to set margin for inner area
    The following works for me with 32x32 images for the ends

    /*inner area*/ QScrollBar::vertical { border: 1px solid #a5a5a5; background: none; width: 65px; margin: 42px 0 42px 0; /* match top/lower area*/ } /*the knob*/ QScrollBar::handle:vertical { background: #d5d5d5;; border: 2px solid #000000; min-height: 60px; border-radius: 12px; } /*lower arrow area*/ QScrollBar::add-line:vertical { border: 0px solid grey; background: NONE; height: 40px; subcontrol-position: bottom; subcontrol-origin: margin; } /*top arrow area*/ QScrollBar::sub-line:vertical { border: 0px solid grey; background: none; height: 40px; subcontrol-position: top; subcontrol-origin: margin; } /*arrows*/ QScrollBar::up-arrow:vertical { image: url(:/GFX/sbar/up_arrow_scrollbar.png); } /*pressed*/ QScrollBar::up-arrow:vertical::pressed { image: url(:/GFX/sbar/up_arrow_scrollbar_pressed.png); } QScrollBar::down-arrow:vertical::pressed { image: url(:/GFX/sbar/down_arrow_scrollbar_pressed.png); } QScrollBar::down-arrow:vertical { /* border: 2px solid grey; width: 3px; height: 23px; */ image: url(:/GFX/sbar/down_arrow_scrollbar.png); } QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { background: none; }
  • 0 Votes
    7 Posts
    13k Views
    SGaistS

    Hi,

    The focus changed when you clicked the button. What you can do is to keep track on the currently focused QLineEdit in a member variable so you can use it at deletion time. Or you could add a remove button besides your QLineEdit and use that to remove them.

  • 0 Votes
    1 Posts
    1k Views
    No one has replied