Questions tagged [qlayout]

The QLayout class, part of the Qt framework, is the base class of geometry managers.

This is an abstract base class inherited by the concrete classes QBoxLayout, QGridLayout, QFormLayout, and QStackedLayout.

Documentation can be found here for Qt 4.8 and here for Qt 5.

239 questions
4
votes
2 answers

delete all QSpacerItem from a layout

I've added a QSpacerItem to a layout using its addStretch() method. layout->addStretch(1); now i'd like to delete it but i didn't have any reference to it. how can I browse all QLayoutItem and only delete QSpacerItem ?
Ghilas BELHADJ
  • 13,412
  • 10
  • 59
  • 99
4
votes
1 answer

Memory management - Does addwidget assign a parent

Say I have something like this void someClass::start() { QLabel* sb = new QLabel(); sb->setText("Hello World"); ui.verticalLayout->addWidget(sb); } Does addWidget make sb a child of someClass so that when I delete someClass sb is also…
MistyD
  • 16,373
  • 40
  • 138
  • 240
3
votes
1 answer

PyQt: Drag'n'Drop based Scrabble UI

I've written a simple Scrabble game with a simple Bot and Human part which can interact using consolebased I/O. Although there is already a Qt based overview of the current situation in the game: A simple custom QWidget which simply paints…
user816328
3
votes
2 answers

how to expand /decrease QTable View without visible blank white space

I have a subclassed QAbstractTableModel to display the data in the Table View in full size without scrolling I have turned of the Scrollbars to get ridd of the white space around the Table View I have set the vertical/horizontal table length to a…
Sator
  • 636
  • 4
  • 13
  • 34
3
votes
1 answer

Stop widgets from overlapping each other and add space between them

I am using QHBoxLayout for layout. The breakdown is: pic.1 is what happens, pic.2 is what I want - widgets don't overlap and there is a gap between them. For pic.2, I created a Gap widget to stick between the existing widgets. But this is a…
user3496846
  • 1,627
  • 3
  • 16
  • 28
3
votes
1 answer

How do I set layout's fixed height in PyQt5?

I am trying to set a fixed height for QHBoxLayout. To elaborate more on that, I need to set a specific height for my Horizontal layout. However, I cannot find the proper way to do so. What should I do to make this happen? hbox1 = QHBoxLayout()
Seungho Lee
  • 1,068
  • 4
  • 16
  • 42
3
votes
1 answer

Add/Remove layout containing multiple widgets pyqt

I'm trying to make a gui that allows the addition/removal of multiple QtWidgets. The user selects a file and has the option off adding a comment in the lineedit next to it. A quick search on this site has so far given me the following code which…
James Porter
  • 119
  • 2
  • 12
3
votes
1 answer

QScrollArea with dynamically added widget

I have some problem placing custom widget in QScrollArea. My custom widget contains 4 labels in QGridLayout filling it. Now I want to keep this widget in QScrollArea and be able to add more labels to it but I want only 4 of them to be shown in…
michszm
  • 113
  • 1
  • 3
  • 10
3
votes
2 answers

QFormLayout equivalent in QtQuick2?

I am in the process of porting a application based on QtWidgets over to QtQuick2. I am trying to figure out what QtQuick layout items I should use. I am stuck at QFormLayout. I simply cannot find an equivalent. The best I could find is a GridLayout,…
feedc0de
  • 3,646
  • 8
  • 30
  • 55
3
votes
1 answer

QWidget::setLayout error : Attempting to set QLayout [...], which already has a layout

On execution (no compile error) I get on the console QWidget::setLayout: Attempting to set QLayout "" on CGSearchResult "", which already has a layout I am using the following code: CGSearchResult::CGSearchResult(QWidget *parent) :…
Finder
  • 8,259
  • 8
  • 39
  • 54
3
votes
2 answers

Set Vertical Alignment of QFormLayout QLabel

I'm using PySide/PyQt, but this is a general Qt question. Is there a way to set up a QFormLayout so that labels are centered vertically without having to explicitly create the QLabel's and set their vertical size policy to expanding first? When the…
flutefreak7
  • 2,321
  • 5
  • 29
  • 39
3
votes
1 answer

QLayout with minimum space required

I have a QVBoxLayout in wich I add dynamically on runtime other QWidget s: for(int i = 0; i < value; i++) { QList widgetList_i; //... widgetList_i.append(a lot of widgets) ui->verticalLayout->addWidget(widget_i); } There is a…
Ralf Wickum
  • 2,850
  • 9
  • 55
  • 103
3
votes
2 answers

How to remove widgets from layout in Qt

I have a piece of code which does this: a method named prepareUI makes the UI ready to be able to load search results that are fed into it. A method named onClear that is called when the results that are already showing needs to be cleared. And a…
SexyBeast
  • 7,913
  • 28
  • 108
  • 196
3
votes
0 answers

Getting notifications about sizeHint changes from internal widgets

Small picture to depict what the problem is: external_widget +--------------------------------------------------+ | | | | | layout_widget …
Daniel
  • 635
  • 1
  • 5
  • 22
3
votes
1 answer

Adding a QLabel to a QWidget

I am new to Qt and C++ and working on an application and I am trying to add QLabel in a QWidget, using QHBoxLayout. I am setting the text of label to something but it is not visible in the Label. Here is the piece of the code: setStyleSheet(…
Sadaab
  • 83
  • 1
  • 1
  • 7
1 2
3
15 16