qapplication

QVideoWidget: Video is cut off

白昼怎懂夜的黑 提交于 2019-12-06 04:34:17
I want to play a video in a Qt Application. This is my code so far: #include <QApplication> #include <QWidget> #include <QMediaPlayer> #include <QVideoWidget> #include <QUrl> #include <iostream> using namespace std; const int WIDTH = 1280; const int HEIGHT = 720; int main(int argc, char *argv[]) { QApplication app(argc, argv); QWidget window; window.resize(WIDTH, HEIGHT); window.setWindowTitle("Video Test"); window.show(); QMediaPlayer *player = new QMediaPlayer(); player->setMedia(QUrl::fromLocalFile("/Path/To/Video.mp4")); QVideoWidget *videoWidget = new QVideoWidget(&window); player-

QOpenGLWidget with QApplication?

落花浮王杯 提交于 2019-12-05 16:04:35
We have a QWidget based application that was previously using a QWindow for OpenGL rendering. To fit that window in our application we had to use QWidget QWidget::createWindowContainer(QWindow); Previously we only used external to Qt OpenGL libraries for rendering. We have a desire to switch from using QWindow to some kind of QWidget for compatibility with touch gestures, and generally better overall compatibility with the rest of our application. The latest recommended OpenGL compatible QWidget seems to be QOpenGLWidget, so we are trying to use that. glContext is an OpenGLContext that we

How to override QApplication::notify in Qt

℡╲_俬逩灬. 提交于 2019-12-05 02:29:47
I am trying to handle exception in my Qt application, I went through a couple of posts which indicated of overriding the QApplication::notify method to handle exceptions in a efficient way in Qt. I am not sure where should I add this overriden method. Is it the mainwindow.h or main.cpp? I added the following function in my MainWindow.h: bool notify(QObject * rec, QEvent * ev) { try { return QApplication::notify(rec,ev); } catch(Tango::DevFailed & e) { QMessageBox::warning(0, "error", "error"); } return false; } When I build my project I get the following error: error: cannot call member

QApplication is lazy (or making other threads lazy in the app)

前提是你 提交于 2019-12-04 02:50:39
问题 This is my first post here and I hope to find a solution to my problem. I have started developing an app for Mac using Qt. I am facing a huge and frustrating problem right now. My problem is QApplication event loop becomes lazy (or makes other threads lazy in the app) after 20-50 seconds. I tried to replicate the same problem and came up with the code below. So here is what I do. I create a c++ new thread and the new thread prints the current time in every 2 seconds. The problem is after 10

Why do I need “sys.argv” to start a QApplication in PyQt?

有些话、适合烂在心里 提交于 2019-12-03 11:50:42
问题 I try to understand what PyQt does. And one of the first things I didn't, was: QApplication(sys.argv) Why do I have to give QApplication this argument? I know what sys.argv does. But in my Scripts I wouldn't need it. 回答1: This calls the constructor of the C++ class QApplication . It uses sys.argv ( argc and argv in C++) to initialize the QT application. There are a bunch of arguments that you can pass to QT, like styles, debugging stuff and so on. Take a look at this for a full list of the

Why do I need “sys.argv” to start a QApplication in PyQt?

不羁岁月 提交于 2019-12-03 02:12:26
I try to understand what PyQt does. And one of the first things I didn't, was: QApplication(sys.argv) Why do I have to give QApplication this argument? I know what sys.argv does. But in my Scripts I wouldn't need it. This calls the constructor of the C++ class QApplication . It uses sys.argv ( argc and argv in C++) to initialize the QT application. There are a bunch of arguments that you can pass to QT, like styles, debugging stuff and so on. Take a look at this for a full list of the options. QApplication takes a list of strings as input. So you can forward sys.argv or simply an empty list:

QApplication is lazy (or making other threads lazy in the app)

别说谁变了你拦得住时间么 提交于 2019-12-01 14:21:03
This is my first post here and I hope to find a solution to my problem. I have started developing an app for Mac using Qt. I am facing a huge and frustrating problem right now. My problem is QApplication event loop becomes lazy (or makes other threads lazy in the app) after 20-50 seconds. I tried to replicate the same problem and came up with the code below. So here is what I do. I create a c++ new thread and the new thread prints the current time in every 2 seconds. The problem is after 10-30 iterations, some iterations take 6-12 seconds which shouldn't happen because I just sleep 2 seconds

What is an event loop in Qt?

随声附和 提交于 2019-11-30 16:48:30
I have understood the following regarding QApplication's exec function: QApplication exec starts the main event loop. It launches the GUI. It processes the signals and calls appropriate slots on receiving them. It waits until exit is called and returns the value which was set in exit. Now, when we say event loop, does it mean that there is some while loop running in the internal code of Qt, and in that while loop the method of handling signals and slots is written? Now, when we say event loop, does it mean that there is some while loop running in the internal code of Qt, and in that while loop

Is it possible to create local event loops without calling QApplication::exec()?

喜欢而已 提交于 2019-11-30 04:03:42
问题 I'd like to create a library built on top of QTcpServer and QTcpSocket for use in programs that don't have event loops in their main functions (because the Qt event loop is blocking and doesn't provide enough timing resolution for the real-time operations required). I was hoping to get around this by creating local event loops within the class, but they don't seem to work unless I've called app->exec() in the main function first. Is there some way to create local event loops and allow for

What is an event loop in Qt?

蹲街弑〆低调 提交于 2019-11-29 22:46:09
问题 I have understood the following regarding QApplication's exec function: QApplication exec starts the main event loop. It launches the GUI. It processes the signals and calls appropriate slots on receiving them. It waits until exit is called and returns the value which was set in exit. Now, when we say event loop, does it mean that there is some while loop running in the internal code of Qt, and in that while loop the method of handling signals and slots is written? 回答1: Now, when we say event