qwidget

QDialog with rounded corners have black corners instead of being translucent

别等时光非礼了梦想. 提交于 2020-01-25 07:04:03
问题 I need to create a QDialog with rounded translucent corners. The problem is when doing so, the corners are translucent, but are somehow filled in by the Window's alpha property making it black (which is my understanding of the cause of the problem) Clearly visible is the rounded edges, but with a black 'background' of sorts. To confirm, this Dialog is a modal dialog launched by a QThread from QMainWindow . It is not the parent window . The CSS for the QDialog (root) component is: QDialog {

Set background colour for a custom QWidget

走远了吗. 提交于 2020-01-24 10:24:25
问题 I am attempting to create a custom QWidget (from PyQt5) whose background colour can change. However, all the standard methods of setting the background colour do not seem to work for a custom QWidget class So far I have attempted to change the colour through QSS stylesheet and by setting the palette. This works for a regular QWidget but for some reason not a custom widget. I have found reference custom QWidgets requiring a paintEvent() function in the C++ documentation https://wiki.qt.io/How

Qt QStackedWidget Resizing Issue

笑着哭i 提交于 2020-01-22 19:00:05
问题 I have a simple QStackedWidget with 3 different QWidgets in it. The minimum sizes of the QWidgets are (350x200), (200x100), and (450x450). So the problem I'm having is when I resize the QStackedWidget, it has a minimum size of the largest QWidget within it. So if I switch to the second QWidget, (which is the QWidget with the size of (200x100)), the QStackedWidget will only size down (450x450) because of the largest QWidget inside of it. I would like it to size down to fit the current QWidget

Ignore minimum size when resizing QWidget

隐身守侯 提交于 2020-01-21 21:44:01
问题 Is there a way to make a QWidget (and any subclass of it) completely ignore its minimum size? What I want is for a QPushButton to cut off when it is sized too small, rather than prevent the window from resizing (the default behavior). 回答1: You can use: button.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored) but you'll have to set the initial size yourself. Or you can just set the minimum size to a small non-zero value: button.setMinimumSize(1,1) To apply that to all buttons within a

Ignore minimum size when resizing QWidget

為{幸葍}努か 提交于 2020-01-21 21:43:48
问题 Is there a way to make a QWidget (and any subclass of it) completely ignore its minimum size? What I want is for a QPushButton to cut off when it is sized too small, rather than prevent the window from resizing (the default behavior). 回答1: You can use: button.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored) but you'll have to set the initial size yourself. Or you can just set the minimum size to a small non-zero value: button.setMinimumSize(1,1) To apply that to all buttons within a

Ignore minimum size when resizing QWidget

亡梦爱人 提交于 2020-01-21 21:43:09
问题 Is there a way to make a QWidget (and any subclass of it) completely ignore its minimum size? What I want is for a QPushButton to cut off when it is sized too small, rather than prevent the window from resizing (the default behavior). 回答1: You can use: button.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored) but you'll have to set the initial size yourself. Or you can just set the minimum size to a small non-zero value: button.setMinimumSize(1,1) To apply that to all buttons within a

QT5.4 remove and delete widget in a layout

喜你入骨 提交于 2020-01-17 01:17:50
问题 I have a QStackedLayout which contains few QWidget on it. The widgets layout is QVBoxLayout which have also few QPushButton . What I wanted to do is to remove all the widgets inside the QStackedLayout and then delete the widgets and layouts BUT I want all the buttons not to be deleted 'cause I will put them to another widget later. Here's my code: while (QLayoutItem *item = m_stacked_layout->takeAt(0)) { QWidget *w = item->widget(); for (int i = 0; i < w->layout()->count(); i++) { QPushButton

QWidget setGeometry show without use of a QLayout

荒凉一梦 提交于 2020-01-16 01:14:13
问题 The target is to paint a QWidget subclass in a other QWidget. By give only the coords. #include <QApplication> #include <QWidget> #include <QLabel> int main(int argc, char *argv[]) { QApplication a(argc, argv); QWidget* w = new QWidget; w->show(); QLabel* l = new QLabel; l->setText("Hello World!"); l->setParent(w); l->setGeometry(0,0,100,100); return a.exec(); } Why i see nothing on the window. 回答1: You must call QWidget::show to show the label since you add it after the parent widget has

How to find only those properties of a widget which are shown in the Qt Designer?

﹥>﹥吖頭↗ 提交于 2020-01-15 10:28:50
问题 How can I find only those properties of a widget (e.g. QPushButton) which Qt Designer shows in the Property Editor ? I can find all properties including those which are not shown in the Qt Designer using the following code: // Print all available properties of a Widget: qDebug()<<qPrintable("Widget: QPushButton"); QObject *object = new QPushButton; const QMetaObject *metaobject = object->metaObject(); for (int i=0; i<metaobject->propertyCount(); ++i) { QMetaProperty metaproperty = metaobject-

QWidget / X11: Prevent window from beeing activated/focussed by mouse clicks

一世执手 提交于 2020-01-13 10:54:10
问题 I would like to develop a system-wide onscreen keyboard in Qt/QML. Injecting key-events via xlib works fine. My problem now: If a keyboard-button is clicked, the window with the selected input field will lose the focus. In consequence, the key event will not be delivered to the previously selected input field. So does anybody know how to prevent a QWidget from beeing activated/focussed by mouse-clicks? Every hint is welcome and a code examples would be great! Thank you very much in advance,