qlayout

Setting text on a QLabel in a layout, doesn't resize

本小妞迷上赌 提交于 2019-11-29 17:12:55
问题 Using the designer in Qt creator I have created a dialog that contains various widgets in a vertical layout. One of the widgets is a QLabel with word wrap set to true. The text for the QLabel is set just before the dialog is shown. The maximum width and height of the QLabel is 16777215, the vertical size policy is set to Expanding and the horizontal is Preferred . I've tried changing changing the size policy. The problem I have is that if the text is large, the QLabel fails to be adjusted

QVBoxLayout: How to vertically align widgets to the top instead of the center

你离开我真会死。 提交于 2019-11-29 00:56:38
In Qt, When I add widgets to my layout, they are vertically centered by default. Is there a way to "List" the widgets from top to bottom instead of centering them vertically? use void QLayout::setAlignment ( Qt::Alignment alignment ) method to set alignment according to your choice. noisygecko I find this a little more complicated than just using layout.setAlignment() . It kept not working for me until just now, when I figured out that if you have expanding widgets that you set a maximum height for, then that widget will not be aligned the way you want. Here is example code that does not top

QLayout: Attempting to add QLayout “” to QWidget “”, which already has a layout

余生颓废 提交于 2019-11-28 22:32:35
问题 I want to create some tabs, and I read this answer: How to add a tab in PySide I use the code in the answer and made some changes. Cause my code has to read some files and get the name of my tabs from those file, so that I add a for loop in my code. And here is my code. from PySide import QtCore, QtGui import sys import dflash_controller as con if __name__ == "__main__": list = [['a', 3], ['b', 4], ['c', 5], ['d', 6]] app = QtGui.QApplication(sys.argv) wid = QtGui.QWidget() grid = QtGui

How to find widgets of a given type in a QLayout?

核能气质少年 提交于 2019-11-28 01:58:16
I am able to find the QRadioButton this way: for(int i = 0; i < ui->verticalLayout->count(); i++) { QRadioButton* r = qobject_cast<QRadioButton*>(ui->verticalLayout->itemAt(i)->widget()); if(r->isChecked()) //found it! } But I don't like this way of iterating over elements and would like to use the foreach construct. My first attempt fails: foreach(QRadioButton* child, ui->verticalLayout->findChildren<QRadioButton*>()) { if(child->isChecked()) //found it! } Problem is that the ui->verticalLayout->findChildren<QRadioButton*>() returns zero elements. It also returns no elements with findChildren

QVBoxLayout: How to vertically align widgets to the top instead of the center

老子叫甜甜 提交于 2019-11-27 15:28:42
问题 In Qt, When I add widgets to my layout, they are vertically centered by default. Is there a way to "List" the widgets from top to bottom instead of centering them vertically? 回答1: use void QLayout::setAlignment ( Qt::Alignment alignment ) method to set alignment according to your choice. 回答2: I find this a little more complicated than just using layout.setAlignment() . It kept not working for me until just now, when I figured out that if you have expanding widgets that you set a maximum

QScrollArea with dynamically changing contents

泄露秘密 提交于 2019-11-27 09:09:27
I have a QScrollArea with some buttons in it, like shown on the picture. The idea of the layout is: 1. The left and right button should be used for scrolling the buttons when they are too wide 2.The numbers of buttons in the scroll area can be changed dynamically 3. Any free space should be used to expand the scroll area as much as possible. If no such space exist navigation buttons should be used for scrolling. With my current implementation when i increase the buttons i have this: But there is free space on the right, so this should look like: If i increase once more to 10 for example, then

Resize window to fit content

风流意气都作罢 提交于 2019-11-27 06:04:27
问题 I have a QGLWidget, which I want to resize to a given resolution (bigger than the containing window). My intention is, that the window expands until the widget fits inside, but can't find a way to do it. I tried several commands after resizing the QGLWidget to make it work without success. I will list the results here: do nothing else: The Widget overlaps the whole window. Eventually it will be resized to fit back into the smaller window mainWindow.adjustSize() : The widget gets resized to (0

How to find widgets of a given type in a QLayout?

时间秒杀一切 提交于 2019-11-26 22:03:22
问题 I am able to find the QRadioButton this way: for(int i = 0; i < ui->verticalLayout->count(); i++) { QRadioButton* r = qobject_cast<QRadioButton*>(ui->verticalLayout->itemAt(i)->widget()); if(r->isChecked()) //found it! } But I don't like this way of iterating over elements and would like to use the foreach construct. My first attempt fails: foreach(QRadioButton* child, ui->verticalLayout->findChildren<QRadioButton*>()) { if(child->isChecked()) //found it! } Problem is that the ui-

QScrollArea with dynamically changing contents

跟風遠走 提交于 2019-11-26 17:48:30
问题 I have a QScrollArea with some buttons in it, like shown on the picture. The idea of the layout is: 1. The left and right button should be used for scrolling the buttons when they are too wide 2.The numbers of buttons in the scroll area can be changed dynamically 3. Any free space should be used to expand the scroll area as much as possible. If no such space exist navigation buttons should be used for scrolling. With my current implementation when i increase the buttons i have this: But there