qtgui

Get visible area of QPainter

半城伤御伤魂 提交于 2019-12-24 01:42:51
问题 I have an owner-drawn QWidget inside a QScrollArea , so when painting, and I want to paint only the parts that are visible. To do so, I need to have the rectangle of the visible area of the QPainter . The only candidates were QPainter::viewport() , QPainter::window() , and QPainter::clipBoundingRect() , so I put this code to log their output: setMinimumHeight(3000); setMinimumWidth(3000); } void MyWidget::paintEvent(QPaintEvent *) { QPainter painter(this); qDebug() << painter.viewport() <<

Qt application with optional gui

北战南征 提交于 2019-12-23 09:36:39
问题 I am going to write program using Qt for some image processing and I want it to be able to run in non-gui mode (daemon mode?). I'm inspired by VLC player, which is "typically" GUI program, where you can configure it using GUI, but you can also run it in non-gui option when it runs without GUI. Then it uses some configuration file created in GUI mode. Question is how should be such a program design? Should be some program core, which is GUI independent and depending on options it is being

Qt Hovering over a button and triggering a function?

不问归期 提交于 2019-12-20 07:21:22
问题 What is the proper way of triggering a function if the mouse cursor hovers over a QButton? To be more precise I have a label called statusLabel which should show message whenever I hover my mouse cursor over a button and should revert back to empty string whenever the mouse is not over it. 回答1: You have to create your own class, derived of QPushButton (or whichever class you want to capture hover events in). In this class, you can override QWidget::enterEvent() to detect when the mouse hovers

PyQt: How to hide QMainWindow

偶尔善良 提交于 2019-12-17 16:31:13
问题 Clicking Dialog_01's button hides its window and opens Dialog_02. Clicking Dialog_02's button should close its windows and unhide Dialog_01. How to achieve it? import sys, os from PyQt4 import QtCore, QtGui class Dialog_02(QtGui.QMainWindow): def __init__(self): super(Dialog_02, self).__init__() myQWidget = QtGui.QWidget() myBoxLayout = QtGui.QVBoxLayout() Button_02 = QtGui.QPushButton("Close THIS and Unhide Dialog 01") Button_02.clicked.connect(self.closeAndReturn) myBoxLayout.addWidget

Display QImage with QtGui

二次信任 提交于 2019-12-17 10:23:41
问题 I am new to Qt, and I am trying to create a simple GUI Application that displays an image once a button has been clicked on. I can read the image in a QImage object, but is there any simple way to call a Qt function that takes the QImage as an input, and displays it? 回答1: Simple, but complete example showing how to display QImage might look like this: #include <QtGui/QApplication> #include <QLabel> int main(int argc, char *argv[]) { QApplication a(argc, argv); QImage myImage; myImage.load(

How to show output video of other application in Qt?

醉酒当歌 提交于 2019-12-14 03:36:31
问题 I am creating a GUI application in Qt. This application is to display output of a application X which is not related to Qt hence i cant integrate it. X will output a video . This video do not have a path since it is a real-time display of X output. I want to show this output in Qt (along with some background GUI support). So as far as my knowledge one way to do this is to get the window id of video and display that same window in QWidget. How to do this? EDIT : I am using Ubuntu. I am able to

Qt: Program not responding despite separate thread

浪尽此生 提交于 2019-12-14 02:48:31
问题 I have a program written with C++/Qt converting certain game files. This is the first time I've done something like this, so I'm not particularly experienced yet. I've had issues with the window occasionally showing the "Not responding..." message. After reading up on it, the problem seemed to be that the processing was done in the main thread, blocking the gui. So I tried running a separate thread for the actual work being done, however the problem still occurs. Here's the section creating

QtGui.QIdentityProxyModel missing in PySide?

陌路散爱 提交于 2019-12-13 15:41:38
问题 I want to write my own proxy model to "flatten" a tree-like model (i.e. some items might have children items) into a list-like model (i.e. no items have children) by mapping the indices. Subclassing QtGui.QIdentityProxyModel seems to be the best way: http://qt-project.org/doc/qt-4.8/qidentityproxymodel.html but I cannot find it in PySide 1.2.1 which is built with Qt 4.8 (which includes QIdentityProxyModel ): http://seanfisk.github.io/pyside-docs/pyside/PySide/QtGui/index.html. So this seems

qt - what's the purpose of initialising child widgets in parent window/widget class?

无人久伴 提交于 2019-12-13 15:01:47
问题 In the VideoWidget and the Secure Socket Client examples in Qt, the code presented there initalises the child widgets in the parent widgets, like so: SslClient::SslClient(QWidget *parent) : QWidget(parent), socket(0), padLock(0), executingDialog(false) and VideoPlayer::VideoPlayer(QWidget *parent) : QWidget(parent) , mediaPlayer(0, QMediaPlayer::VideoSurface) , playButton(0) , positionSlider(0) , errorLabel(0) However, further down the code, I see the following: playButton = new QPushButton;

How to access the GUI output?

泄露秘密 提交于 2019-12-13 10:32:06
问题 I'm developing one test bench which runs multiple tests via python gui and prints the output as below. A Passed B Passed C Passed D Passed E Passed Button from gui should be changed to 'Passed' only when A,B,C,D,E all are Passed. If any of these tests fails, it should say failed. What is the way to access this output from gui which is printed on screen. My code for tests is: from PyQt4.QtCore import * from PyQt4.QtGui import * import sys, os, time from PyQt4 import QtGui, QtCore from progress