qwidget

QT How to embed an application into QT widget

a 夏天 提交于 2019-11-28 21:41:40
In our project we have three independent applications, and we have to develop a QT control application that controls these three applications. The main window will be seperated to three sub windows - each one display another one application. I thought to use QX11EmbedWidget and QX11EmbedContainer widgets, but two problems with that: The QX11Embed* is based on X11 protocol and I dont know if it's supported on non-x11 systems like Windows OS. Since QT 5 these classes are not existing, and the QT documentation doesn't mention why. So that I dont know whether to use it or not - I'll be happy to

What is the difference between a QWindow and QWidget

牧云@^-^@ 提交于 2019-11-28 17:08:55
问题 The Qt 5.0 provides a new QWindow class. While the documentation on this class is quite comprehensive, I am failing to see how exactly the QWindow is different from the QWidget class, and in which cases you would prefer the former. Both provide a handy way of visualising all sorts of things to the screen, both can use QPainter for drawing, and both have a way to interact with OpenGL. In the API description, it says that: An application will typically use QWidget or QQuickView for its UI, and

Qt Hide Taskbar Item

让人想犯罪 __ 提交于 2019-11-28 09:01:04
I have a custom QWidget and I simple don't want it to show up in the taskbar. I have a QSystemTrayIcon for managing exiting/minimizing etc. I think the only thing you need here is some sort of parent placeholder widget. If you create your widget without a parent it is considered a top level window. But if you create it as a child of a top level window it is considered a child window und doesn't get a taskbar entry per se. The parent window, on the other hand, also doesn't get a taskbar entry because you never set it visible: This code here works for me: class MyWindowWidget : public QWidget {

Keeping the aspect ratio of a sub-classed QWidget during resize

五迷三道 提交于 2019-11-28 07:11:04
问题 I'm creating a new widget, by subclassing the QWidget class. I'd like to be able to set a ratio (for its height and its width) for this widget, which will always be maintained. For this, I've always searched, using the Qt5 documentation, Google, and Stackoverflow. Obviously, I've found answers: in particular, this one. But, unfortunately, not even one is fully effective: Setting the sizeIncrement does totally nothing, even if the widget is a window I tried to overload resizeEvent, but I

PyQt: Detect resizing in Widget-window resized signal

人盡茶涼 提交于 2019-11-28 01:23:32
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("centralwidget") MainWindow.setCentralWidget(self.centralwidget) MainWindow.resized.connect(self.someFunction)

How to Clear all the Widgets in Parent Widgets?

隐身守侯 提交于 2019-11-27 23:29:58
问题 I am using the constructor QWidget(QWidget *parent) . This parent widget contains a lot of child widgets. I need to clear all the child widgets from the parent at runtime. How can I do this? 回答1: You can use the following in your parent widget class: QList<QWidget *> widgets = findChildren<QWidget *>(); foreach(QWidget * widget, widgets) { delete widget; } 回答2: Previous answer is wrong!! You cannot use findChildren to delete a widget's children, because Qt4's findChildren recursively lists

Is there a way to access the image on the QWidget's backing store?

懵懂的女人 提交于 2019-11-27 09:34:49
I'm doing some compositing inside the paintEvent() in a custom widget. Some of the compositing is done when some areas are already painted, and I need access to the current contents painted so far. So, I'm looking for a way to access the image contents of the current backing store during a paintEvent . I've looked at QBackingStore , but there's nothing there that directly gives me access to the backing store bitmap. Is there some API, perhaps private, that could be used to provide that? If not, I'll have to resort to painting on an explicit pixmap and rendering that pixmap onto the widget. It

Must construct a QApplication before a QWidget

白昼怎懂夜的黑 提交于 2019-11-27 08:23:03
问题 Everywhere only just "before QPaintDevice" questions and nowhere is my error. So, here we go. I need an extern QWidget to be able to get access to it from outside (because I don't know any other ways to do it). Basically, I need this: Create 2 QWidgets from 1 window, go to first window and from there hide main window and show second window created by main window (although main window is not main(), it is QWidget too). I added extern QWidget *widget = new QWidget everywhere and everyhow in

QWidget does not draw background color

邮差的信 提交于 2019-11-27 05:20:21
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's the ui-XML: <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>MainWindow</class>

How to change a parent widget's background when a child widget has focus?

末鹿安然 提交于 2019-11-27 02:52:02
问题 I would like to highlight a QFrame, if one of it's child widgets has focus (so the users know where to look for the cursor ;-) using something along ui->frame->setFocusPolicy(Qt::StrongFocus); ui->frame->setStyleSheet("QFrame:focus {background-color: #FFFFCC;}"); highlights the QFrame when I click on it, but it loses its focus once one of its child widgets is selected. Possible approaches: I could connect() QApplication::focusChanged(old,now) and check each new object if it is a child of my