Skip to content
  • ListView with Flow layout

    Unsolved QML and Qt Quick qml listview layout
    3
    0 Votes
    3 Posts
    223 Views
    A
    @SuhasKrishanamurthy, thanks for your help, but the GridView component has fixed cell's width and height. Items' height can grow up, but if it will be greater than cell's size, the collision occures. If I adjusted GridView's cell size depending on size of largest item, there were too much free space between small items. The following code lays items out with collision: GridView { id: gridView width: 600 height: 400 cellWidth: 200 cellHeight: 100 flow: GridView.FlowTopToBottom model: ListModel { ListElement { value: "Lorem ipsum dolor sit amet, consectetur adipiscing elit" } ListElement { value: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." } ListElement { value: "Lorem ipsum dolor sit amet" } ListElement { value: "Lorem ipsum dolor sit amet" } ListElement { value: "Lorem ipsum dolor sit amet" } ListElement { value: "Lorem ipsum dolor sit amet" } ListElement { value: "Lorem ipsum dolor sit amet" } ListElement { value: "Lorem ipsum dolor sit amet" } ListElement { value: "Lorem ipsum dolor sit amet" } ListElement { value: "Lorem ipsum dolor sit amet" } ListElement { value: "Lorem ipsum dolor sit amet" } ListElement { value: "Lorem ipsum dolor sit amet" } ListElement { value: "Lorem ipsum dolor sit amet" } ListElement { value: "Lorem ipsum dolor sit amet" } ListElement { value: "Lorem ipsum dolor sit amet" } ListElement { value: "Lorem ipsum dolor sit amet" } } // orientation: Qt.Horizontal // GridView doesn't have this property boundsBehavior: Flickable.StopAtBounds clip: true delegate: Item { width: gridView.cellWidth height: contentItem.implicitHeight required property string value Rectangle { id: contentItem width: parent.width color: "lightgray" implicitHeight: tex.implicitHeight + 20 Text { id: tex text: value wrapMode: Text.WordWrap anchors.margins: 10 anchors.fill: parent } } } } [image: 5511da81-8d79-4306-a3e0-805fb1a8683a.png] The desired behavior is lay items out onto the first column until it has free space and then turn into the next column (see picture in the question). Unfortunately, GridView lays item out strictly as a grid. This is partially implemented with Flow + Repeater layout: [image: 0887646e-c6a2-4106-b30c-ff9f8b07a38f.png]
  • are there only five kinds of layouts in Qt?

    Solved General and Desktop qt 6 qlayout layout
    4
    0 Votes
    4 Posts
    365 Views
    Pl45m4P
    @markleo said in are there only five kinds of layouts in Qt?: Or are there only five kinds of layouts in Qt? Yes and no. In most cases these are the base layouts used. However there are also custom layouts with "special" behavior, like FlowLayout from the Flow Layout Example. That being said, you can combine the basic layout or build your own layout, if you really need something different (what you cannot reproduce using the five above).
  • 0 Votes
    2 Posts
    323 Views
    johngodJ
    Don't use anchors for the dot, use a fixed value, something like Image { id: dot width: someWidth height: someHeight x: someXPositionRelativeToXBodyImage y: someYPositionRelativeToYBodyImage ..... }
  • QToolbox changes width

    Unsolved General and Desktop layout qtoolbox
    3
    0 Votes
    3 Posts
    363 Views
    M
    @mpergand Thanks - this is what I've done but it's not ideal as there two boxes have different "natural" widths as it were, and forcing a proportional size on them is a bit of a kludge. Better than not - but you'd like to think it it shouldn't be needed.
  • 0 Votes
    5 Posts
    616 Views
    Pl45m4P
    @Axel-Spoerl said in QWidget Drag And Drop inside Layout. Is this a good way?: I have troubles to imagine what you mean by that. Colors aside, a widget is typically a rectangle. If I want to indicate a potential landing spot, I'd rather use a rectangle, than a line. I think @StudentScripter means the same behavior you see when adding widgets to a layout in QtDesigner. A "line" can be a thin rectangle :) You also see a rectangle when dragging QDockWidgets around showing the valid DockAreas. Maybe check the source code of QtCreator's Designer or QMainWindows dockarea.
  • Storing and setting widget values using arrays?

    Unsolved General and Desktop qt c++ array widget layout
    3
    0 Votes
    3 Posts
    590 Views
    JonBJ
    @StudentScripter You can put pointers to widgets into arrays/lists/maps as you please and use those for iterating through them etc. You can't get Designer to do that for you, so you have to manually populate the arrays/lists from the ui->... instance variables yourself (after setupUi()). You can also visit all widgets of a given type, without setting anything up, via topWidget->findChildren<QLineEdit *>(). You can "group" widgets at design-time by e.g. creating a "holding" container QWidget or QFrame or QGroupBox if that helps. For buttons there is also QButtonGroup.
  • 0 Votes
    5 Posts
    672 Views
    M
    @fokhagyma QDesigner is not the best/fancy app in the world.
  • QDialog default layout is NULL

    Solved General and Desktop qdialog layout fixed sizehint setfixedsize
    3
    0 Votes
    3 Posts
    561 Views
    K
    @ChrisW67 Thanks for replying. I was doing as you suggested but still getting the behaviour I specified. Turns out I had a conflicting ui generated header file that had the manually added layout which explains why I was experiencing a NULL layout. Once I deleted the conflicting file everything worked as expected. Thanks for the extremely easy to follow instructions. Kevin
  • drawRect not show left and top border line

    Unsolved General and Desktop paintevent layout drawrect
    4
    0 Votes
    4 Posts
    704 Views
    Christian EhrlicherC
    You should create a bug report about this with a minimal, compilable example. I took a short look at the code but can't see any obvious here.
  • مشکل با layoutها و سیستمهای high dpi

    Unsolved Persian high dpi layout design editor
    1
    0 Votes
    1 Posts
    640 Views
    No one has replied
  • 0 Votes
    5 Posts
    1k Views
    bibasmallB
    @Chris-Kawa, oh, pardon my blindness, it really works. I found that the stylesheet is resetting the width of the button in my case.
  • 0 Votes
    13 Posts
    1k Views
    JonBJ
    @JonB You have (for unknown reason) placed a button at row #5 column #6 and spanning 5 rows and 2 columns. It's not going to make much sense, is perhaps not what you intend, and will move around when you place other widgets on the grid layout. I know nothing about "In the gray square there should have been a cube. that I opened", The second shot shows about what I expect when you didn't use any layout. If the 3 lines of text there were deliberate you would need to put them into the layout now if you expect to see them.
  • 0 Votes
    4 Posts
    2k Views
    EmrecpE
    @Chris-Kawa This worked, thank you very much!
  • 0 Votes
    9 Posts
    2k Views
    JoeCFDJ
    @leonardoMB said in Why Layout is reparenting to the top most widget through addChildLayout?: What will make _qButton child of widget_1. Where did I go wrong? printing it I have that all are child of widget_1 What will make _qButton child of widget_1? _qButton = new QPushButton( widget_1 ) or _qButton->setParent( widget_1 ); will make _qButton the child of widget_1. The layouts of widget_1 can have children of other widgets.
  • 0 Votes
    5 Posts
    808 Views
    B
    I see. Thank you.
  • Offset QLabel from widget center.

    Solved General and Desktop layout
    3
    0 Votes
    3 Posts
    780 Views
    A
    @JoeCFD That in combination with setMaximumSize seems to work, thanks!
  • Newbie Help with Code

    Unsolved General and Desktop layout source code mobile
    11
    0 Votes
    11 Posts
    2k Views
    N
    Ok, how about this - Anybody know a way I can add code or set env to enable rotation, (portrait/landscape, or...). As it is, the qt apps don't respond to phone sensors, but are fixes...
  • 0 Votes
    8 Posts
    2k Views
    SGaistS
    Great ! Since you have it working now, please mark the thread as solved using the "Topic Tools" button or the three dotted menu beside the answer you deem correct so that other forum users may know a solution has been found :-)
  • QLabels have same width regardless of text?

    Unsolved General and Desktop qlabel layout widget
    9
    0 Votes
    9 Posts
    3k Views
    H
    @eyllanesc Oh I see, it's working now. Thank you!