qgridlayout

QML Layouts: How to give weights to items in a row or column layout?

廉价感情. 提交于 2021-02-16 16:30:10
问题 I'm trying to figure out a way to layout items proportionally by specifying a kind of weight for each item. For example the way Android does their layouts. The way I'm trying to achieve it is like so: import QtQuick 2.10 import QtQuick.Controls 2.3 import QtQuick.Layouts 1.3 GridLayout { columns: 4 width: 640 height: 480 Rectangle { color: "red" Layout.fillHeight: true Layout.fillWidth: true Layout.columnSpan: 1 } Rectangle { color: "#80000000" Layout.fillHeight: true Layout.fillWidth: true

Qt: How can I align widgets in two different QGridLayouts?

偶尔善良 提交于 2021-01-29 09:30:21
问题 I am trying to line up widgets from two different QGridLayouts. The idea is the following: I have many rows of widgets in the QGridLayout of a scroll frame. Each row contains maybe 8 columns of other widgets (so a grid of 8xN widgets, N = # of rows). The first widget in that row is a show/hide button that when checked, will show another widget with the same layout just below that row (i.e. that shown widget has rows of widgets, each row has 7 columns of widgets). So the shown widget will be

GridLayout Arrangement

社会主义新天地 提交于 2021-01-28 02:25:43
问题 Following is my main.qml : Window { id: window visible: true width: 800 height: 480 title: qsTr("Hello World") ListModel { id: _listModel ListElement { textData: "E1" isEnabled: false } ListElement { textData: "E2" isEnabled: false } ListElement { textData: "E3" isEnabled: false } ListElement { textData: "E4" isEnabled: false } ListElement { textData: "E5" isEnabled: false } ListElement { textData: "E6" isEnabled: false } } ListView { id: _listview model: _listModel width: 100 height: parent

PyQt: Is it possible to drag/drop QWidgets in a QGridLayout to rearrange them?

旧时模样 提交于 2020-04-16 05:47:13
问题 I am looking for a way to create a grid of graphs that can be dragged/dropped to rearrange the order. My first try was using QDockWidgets as they allow for drag/drop, however they were limited in a lot of other ways. Would it be possible to implement this function in a QGridLayout? For now I have a QGridLayout with 3x3 matplotlib widgets. Here is an example of the desired layout outcome. Sample code: import sys from PyQt5 import QtWidgets from matplotlib.figure import Figure from matplotlib

QGridLayout different column width

為{幸葍}努か 提交于 2020-01-12 10:42:53
问题 I am trying to create a layout looking like this: _________ | | | |1 | 2 | |__|______| | 3 | 4 | |____|____| Basically, I want cell number 1 the first row to be thinner that cell 2, but cells number 3 and 4 on the second row should have equal widths. Is it even possible to create a layout like this using QGridLayout in PyQt4? 回答1: The task of QGridLayout is to create that type of structure, for this you must use the function: void QGridLayout::addWidget(QWidget * widget, int fromRow, int

Up or down lines of widgets

别来无恙 提交于 2019-12-25 18:05:32
问题 In a application I create lines of widgets like this (there is a button to create the line and another to remove the widget): Code for creation of the widgets lines : def ajouter_ref_artistique(self) : ''' Gestion des widgets (AJOUTER widgets) partie Références artistiques ''' # Nombre d'éléments présents try : # ... r = len(self.l_t_ref_art) except : # ... r = len(self.liste_ref_artistiques) # Création des QTextEdit self.dico_chem_ref_art[r] = QTextEdit() self.dico_com_ref_art[r] = QTextEdit

Up or down lines of widgets

雨燕双飞 提交于 2019-12-25 18:05:28
问题 In a application I create lines of widgets like this (there is a button to create the line and another to remove the widget): Code for creation of the widgets lines : def ajouter_ref_artistique(self) : ''' Gestion des widgets (AJOUTER widgets) partie Références artistiques ''' # Nombre d'éléments présents try : # ... r = len(self.l_t_ref_art) except : # ... r = len(self.liste_ref_artistiques) # Création des QTextEdit self.dico_chem_ref_art[r] = QTextEdit() self.dico_com_ref_art[r] = QTextEdit

QToolButton with text: Overwrite minimal height to minic regular button height

爱⌒轻易说出口 提交于 2019-12-24 18:00:54
问题 I am displaying QToolButtons with icon plus text ( Qt::ToolButtonTextBesideIcon ) outside of a tool bar. Each button has a QAction associated with it which determines the used icon and the displayed text. All those buttons are placed inside a QGridLayout. So far so good. Unfortunately, it looks like that as soon as you add a QAction to a QToolButton, Qt automatically decides to shrink it down to the minimal size, which is not what I want given my QGridLayout. I used the following lines to

Removing widgets from QGridLayout

随声附和 提交于 2019-12-17 16:27:56
问题 I try to remove widgets from a specified row in a QGridLayout like this: void delete_grid_row(QGridLayout *layout, int row) { if (!layout || row < 0) return; for (int i = 0; i < layout->columnCount(); ++i) { QLayoutItem* item = layout->itemAtPosition(row, i); if (!item) continue; if (item->widget()) { layout->removeWidget(item->widget()); } else { layout->removeItem(item); } delete item; } } But when I call it, the app crashes with SIGSEGV on delete item in the first iteration. Any ideas? 回答1

Insert Image into QGridLayout and Draw on top of image in PyQt5

我只是一个虾纸丫 提交于 2019-12-12 16:18:01
问题 I'm pretty new to PyQt and am trying to make an application with a QPixmap on the left, which can be drawn on, and a QTextEdit on the right (for a simple OCR GUI). I looked at: PyQt5 Image and QGridlayout but I couldn't connect it with the code below (I'm losing my hair with all the head scratching!!) When I try adapting the following code, what I get is a QMainWindow with the QPixmap as the background which can be drawn on with the mouse and a second occurance of the QPixmap in it's correct