display Qprocess output window inside the QT mainwindow - qt

how to display Qprocess output window inside the QT mainwindow? I am calling ffplay by Qprocess. the video playing in a detached window? how would i play the video in same application QTwindow

I don't know ffplay but it seems that ffplay is opening the window by itself. One approach is that you could try to get the current image and display that in your mainwindow. Every time a new image is available you have to replace the image in your ui with the new one. Of course you have to keep synchronization in mind, since this application is not single-threaded.
In general your approach looks not right. You shouldn't call a program to do that kind of task. Normally you use a library for that.
You should have a look at this example to get an idea what I'm talking about: https://doc.qt.io/qt-5/qtwidgets-widgets-movie-example.html

Related

How can I use a QProgressDialog as a simple wait dialog without QProgressBar?

There is an operation in my application that can take up-to few minutes to finish. I wish to show a simple dialog box which opens when the operation begins, displays a simple wait message like 'Operation in progress..' and closes automatically when the operation finishes.
To implement above functionality, I am trying to make use of a QProgressDialog which does not have a QProgressBar. It seems to work fine but I am unable to set the wait message. Following is the code:
QProgressDialog progress(this);
QLabel *lblCustom = new QLabel(&progress);
progress.setBar(new QProgressBar());
progress.setValue(0);
progress.setLabel(lblCustom);
progress.setLabelText("Operation in progress. Please wait...");
progress.setMaximum(0);
progress.setMinimum(0);
progress.setModal(true);
progress.setWindowTitle("Validate field data");
progress.setCancelButton(0);
progress.setFixedSize(400, 100);
progress.setWindowFlags(progress.windowFlags() & ~Qt::WindowCloseButtonHint);
progress.show();
// operation
progress.close();
Setting label text does not seem to work. Please let me know what is wrong here? I am relatively new to Qt.
To solve the actual problem, I was used QLabel as a dialog instead of QProgressDialog and invoked QApplication::processEvents(), to make sure QLabel window gets painted with suitable text as well.
I suggest you create a new widget, then you can customize as you like. You can insert images and labels and you can create your own methods (including signals and slots). It will take a little longer to implement but it will be much more flexible and extensible.

How to show exteranal window in qml-based application

I have an application that gui is made up with QML. The task is to start an external program (LibreOffice) "inside" my application. It means that when you press the button on the app's face, external program must be shown in the same window as the main program is. And also it can be closed by app's button that is drown under the external window.
The only thing that I could do for the moment is to start lowriter with QProcess using this article. But it is still shown in separate window and I don't know how to make a button that will close lowriter.
If somebody have any thoughts about how to do this, it would be great if you share it.. Thanks!

A real top level window with Qt?

I use the last Qt version for a projet and QProcess. I want to lauch program from my application by using QProcess. I want to display a QGraphicsView transparent on full screen over the launched program.
For the moment: I hide the view, launch the program, sleep during 5 seconds and show the view. I want that my view keep the focus and stay on the top level? Is there any better way to do that? A custom setting for the QGraphicsView?
Create your QGraphicsView (or the window that contains it) with the Qt::WindowStaysOnTopHint flag
Once you run a program in QProcess, you have limited control over it. Qt does not provide details about other applications that are running, you won't know where the launched application is being displayed unless it tells you explicitly.
If you have access to the code of the application you're running, it is possible put a transparent overlay on top a given widget, or widgets, that could then record mouse clicks and other interactions. It's also possible to override events and record basic information about the application's use.

Attach Qt windows?

Is there any way to attach two Qt windows together? For example, if window A is the main window and window B is another widget I want to be able to show window B to the side of A and have both windows move together if the windows are dragged.
Not that I am aware of, but you can try following the trail of QMoveEvent. When a given widget is moved void QWidget::moveEvent ( QMoveEvent * event ) is called, and the QMoveEvent contains both old and new pos. Using this information, you can inject a move event in the other widget as well, and make it follow.
Of course, I am speaking of two independent widgets, each one in its own window. If they are contained, you don't need anything but a Layout management (see QLayout and related classes).
I don't work with Qt since a long time, so there could be a better method, but if I had to do it right now, this is the strategy I would use.
Also, I have the feeling that the QMoveEvent will be invoked only at start and end, unless you enable mouse tracking. If the former is the case, you will obtain that the other widget will "teleport" at the end of the move, instead of following smoothly.
You might be after something like this:
http://doc.qt.io/archives/4.6/qt4-mainwindow.html
Window A would be a QMainWindow and window B would be a QDockWidget.

Force immediate paint in JavaFX

Is there a way to force a JavaFX app to repaint itself before proceeding? Similar to a Swing Panel's paint(Graphic g) method (I might be getting the keywords wrong there).
Consider the following example: you write a TicTacToe app along with the AI required for a computer player. You would like the ability to show two computer players duke it out. Maybe you put in a two second pause between computer turns to give it a life-like affect. When you hit your "Go" button, there's a large pause of unresponsiveness (the time it takes for the 9 turns to go by with faked pauses for the computer to 'decide') and then suddenly the app's visual is updated in with the completed game's state.
It seems like JavaFX repaints once processing in the app's thread is finished? I'm not completely sure here.
Thanks!
You are right. JavaFX is event-driven and single-threaded. This means that repaint and event response can not be done simultaneously. Long-running task should be executed on separate thread so they do not block the rendering of the UI, When the task is finished it can sync back to the FX thread by calling FX.deferAction() which will simply execute the code on the main thread.
This won't be the most helpful answer as I have toyed around with JavaFX for all of half a day, but wouldn't you use Timelines, Keyframes, and binding to accomplish your repaints instead of calling them explicitly like you have described?
See this tutorial for an example.
JavaFX's model is to separate you from the painting of the "stuff" on the screen. This is very powerful but is a change from how you might be familiar with.
whaley is correct that the appropriate way of doing this in JavaFX is to make a timeline where the move is done every X seconds and will be drawn at that keyframe.
If you have a question about how to do this, try it and make a new question with some code.

Resources