Important: Please read the Qt Code of Conduct -

LineEdit with a horizontal ScrollBar

  • Greetings.

    I need a widget that is a LineEdit, but that has a horizontal scrollBar in case the text is too long. I really do not need a custom widget, rather I would like to achieve that effect and appearance combining built-in Qt widget (that's what been trying so far). I have tried to do this in QtDesigner putting a QLineEdit inside a QScrollArea, but the problem is that it takes up too much vertical space. I want the ScrollArea this adjusted around the LineEdit and like that it can not grow vertically, only horizontally, so the widget will seem a simple LineEdit and horizontal scrollBar only appear when needed.

    How I can achieve this effect?
    Can this be done only by combining a QLineEdit and QScrollArea or I'm wrong?

    Thanks in advance for any help and/or suggestions.

  • Hi,
    If you only want to use QtWidgets, yes, I believe this is the proper way. Was the first thing that came to mind.
    With the stylesheet options a lot of display properties may be changed for the scrollBar, so probably also the height/width etc of the bar.

Log in to reply