qwidget

QLabel does not display in QWidget

狂风中的少年 提交于 2019-11-26 23:13:28
I have the following hierarchy in my Qt Application: QMainWindow > QWidget (centralWidget) > QWidget (subclassed) > QLabel Initialization code in my QMainWindow code: centralWidget = new QWidget(); centralWidget->setGeometry(0,0,width,height); chatWidget=new ChatWidget(this); // the subclassed QWidget setCentralWidget(centralWidget); In my subclassed QWidget initialization (which happens at the same time than the Qt App initialization) I have the following code: ChatWidget::ChatWidget(QWidget *parent):QWidget(parent) { QLabel *lbl; lbl=new QLabel(this); lbl->setText("Hello World 1"); <-- Is

Detect resizing in Widget-window resized signal

邮差的信 提交于 2019-11-26 21:56:05
问题 I create a simple UI with Qt Designer and convert it to Python codes. I searched for any method to detect changing window size. This is the generated code : from PyQt5 import QtCore, QtGui, QtWidgets class Ui_MainWindow(object): def onResize(event): print(event) def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.setWindowTitle("MainWindow") MainWindow.resize(200, 200) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName(

Draw Rectangular overlay on QWidget at click

怎甘沉沦 提交于 2019-11-26 13:45:53
in my project i use a EventFilter for widgets, that are in a QHBoxLayout . If i clicked on an a widget, i want to draw a transparent overlay with blue color over the clicked widget. Is there a way to implement this? greetings This answer is in a series of my overlay-related answers: first , second , third . One way of doing it is: Have a semi-transparent overlay widget that is also transparent to mouse events. In the event filter, track the clicks and the resizing of the objects by adjusting the overlay's geometry to match that of the target widget. The self-contained example below works under

Qt5. Embed QWidget object in QML

核能气质少年 提交于 2019-11-26 13:31:52
I am using Qt5 beta and trying to embed a QWidget-based object into QML. The goal is to use QML as much as possible, and only use QWidget objects where QML does not do what I need. I found a link explaining how to do this for Qt4.7, but I have not found any information explaining how to do this in Qt5. http://doc.qt.digia.com/4.7/declarative-cppextensions-qwidgets.html The same example is also available in the Qt5 examples folder under: examples\qtquick1\declarative\cppextensions\qwidgets Unfortunately, this example uses QtQuick 1, rather than QtQuick 2, and I would like to use the new

How to make an expandable/collapsable section widget in Qt

六月ゝ 毕业季﹏ 提交于 2019-11-26 12:21:51
问题 I would like to create a custom widget in Qt with the following features: It is a container It may be populated with any Qt layout It may be inside any Qt layout A button allows to collapse/fold vertically the content, so only the button is visible, all the contained layout is invisible. The previous button allows to expand/unfold it again to the size of the layout content. The expanding/collapsing is based on sizes (not on show/hide) to allows animation. Usable in QDesigner To provide an

QWidget does not draw background color

自古美人都是妖i 提交于 2019-11-26 11:31:07
问题 I am using PySide 1.2.1 with Python 2.7 and I need a widget to draw a colored background. In Qt Designer I created a simple window consisting of a label, a widget containing three other items and another label. For the widget containing the button, radio button and checkbox I set the styleSheet property to background-color: #FFFFFF . In Qt Designer everything renders as desired: But in Pyside the widget does not draw the background color - but the items on it inherit the color correctly: Here

QLabel does not display in QWidget

主宰稳场 提交于 2019-11-26 06:08:21
问题 I have the following hierarchy in my Qt Application: QMainWindow > QWidget (centralWidget) > QWidget (subclassed) > QLabel Initialization code in my QMainWindow code: centralWidget = new QWidget(); centralWidget->setGeometry(0,0,width,height); chatWidget=new ChatWidget(this); // the subclassed QWidget setCentralWidget(centralWidget); In my subclassed QWidget initialization (which happens at the same time than the Qt App initialization) I have the following code: ChatWidget::ChatWidget(QWidget

Draw Rectangular overlay on QWidget at click

随声附和 提交于 2019-11-26 03:44:29
问题 in my project i use a EventFilter for widgets, that are in a QHBoxLayout . If i clicked on an a widget, i want to draw a transparent overlay with blue color over the clicked widget. Is there a way to implement this? greetings 回答1: This answer is in a series of my overlay-related answers: first, second, third. One way of doing it is: Have a semi-transparent overlay widget that is also transparent to mouse events. In the event filter, track the clicks and the resizing of the objects by

Qt5. Embed QWidget object in QML

╄→гoц情女王★ 提交于 2019-11-26 02:37:28
问题 I am using Qt5 beta and trying to embed a QWidget-based object into QML. The goal is to use QML as much as possible, and only use QWidget objects where QML does not do what I need. I found a link explaining how to do this for Qt4.7, but I have not found any information explaining how to do this in Qt5. http://doc.qt.digia.com/4.7/declarative-cppextensions-qwidgets.html The same example is also available in the Qt5 examples folder under: examples\\qtquick1\\declarative\\cppextensions\\qwidgets