I'm new in Choregraphe and programming Pepper. I tried use the function Show Image at the Choregraphe (version 2.5) and wanted to create a slide shows for my images. It works when only 1 image or 1 ShowImage Function Box, but when i connect it with a delay and 2nd ShowImage box, it just won't works and only the first image will be displayed in the Pepper's tablet and not the 2nd image. There seems like no output from the first ShowImage box to continue the sequence as the input for the delay function.
The output of the 1st Function is set as "Bang" type and nature of "onstopped"
Any can help on this?
There is no output because the output bang is generated when the box "stops", meaning the image is not being shown anymore. That doesnt happen unless you manually stop it.
Try linking a first wait box to the start of th behaviour so it starts ticking as soon as it starts and then use the output bang from this wait box to trigger the second image and a new wait box which will trigger a third image and wait box and so on.
There are several more elegant ways to do this with events, but if you want to keep it simple, the above will work.
EDIT: I'll add an image for reference
Related
in documentation of Magick++ I found the command to display an image
Image temp_image(my_image);temp_image.display(); // display 'my_image' in a pop-up window
this works quite well, but I can find a command to close this window by code.
My goal is to open a window with the image, give image new name by commandline input, then automatically close the window, and show next image to rename.
Although the new popup-window sets the "active window" to it's self.
For entering some input to command line (e.g. new_name), I have to click again at the terminal window.
My (pseudo)code at the moment:
for(all_images){temp_image.display(); renaming_method();}
just now I have to close the upcoming window manualy by hand, better would be something like
for(all_images){temp_image.display(); renaming_method(); temp_image.display_close();}
do you have any ideas how to do this?
Magick++, and ImageMagick, doesn't have any methods to manage active display windows. You can roll your own XWindow method, but most projects I've seen just do the following routine...
Write temporary image
Ask OS to open temporary file by forking a process & calling xdg-open, open, or start commands (depending on OS).
Send SIGINT to pid when user wishes to close child process.
Clean-up any resources
Not ideal, but will get you roughly there.
Hi I have a question concerning error-messages.
I have a window with several buttons including a OK and Cancel-button. My OK-button executes a program that moves some chart series and for doing so it needs to read in lots of data from a file and shift these values. The Cancel button cancels this operation. The calculations cannot be separated into smaller portions of code.
This works well for smaller amount of data but when I use it with large sets of data the program acts as if it crashed. Nevertheless, after some time everything is back to normal, the calculation is done.
There are 2 things I don`t like:
1) When I leave the program alone the program changes the headerline of my window to ....(keine Rückmeldung) which means no response.
After the end of the calculation the text ...(keine Rückmeldung) disappears in the header and everything is back to normal.
2) When I try to press the "cancel" button in my window while running the calculation, an additional window appears:
There again, when I leave the program alone and the calculation is finished this window disappears ( as well as the (keine Rückmeldung) in the header of my window) and and everything is back to normal.
To solve problem 2 I tried to disable my "Cancel" button but this does not help. The slot which is behnid the cancel-button gets executed anyway.
My question now is: Since I don´t want the user to see these error-messages, is there a way to prevent the program of showing them?
Thank you
Consider using a QThread for expensive computation tasks. Or better, you can use other built-in multi-threading utilities such as QConcurrentRun and QFuture.
You can then easily get the state of your background function and show a loading Window, or allow the user to perform other operations in the meantime.
i try to make GUI Application in QT Creator.İ wanna display all images from chosen directory (a sort of slide show),i read QDir,QStringlist,QFileDialog class references but it doen't work.it shows only last image in folder.
for(int i=0;i<10;i++)
{
QImage image2(directory+"/"+fileList[i]);
ui->label_pic2->setPixmap(QPixmap::fromImage(image2));
//Sleep(550);
}
Sleep function only makes to load slowly not to show one by another.
First you need to undertand that GUI is only updated when you code is not executed and the application can process incoming events. If you create an endless circle your GUI will neved be updated. That's why you can see only the last image - because you don't let GUI to be updated.
You can force the application to process incoming events by QCoreApplication::processEvents(). In this case you will probably see quick flashing of images. But you will certainly need to make a pause after showing of each image. And your Sleep will probably work there, but during the pause your application will be freezed without being able to process the events.
That's why you have been suggested to use QTimer. It calls a slot in a certain amount of time. All the other time the application is processing messages and updates GUI and so on. When the slot is called you can switch label to show the next image. And this is exactly what you need.
Summary:
1. Create a QTimer, set interval and connect it to a slot, start the timer.
2. In the slot implementation read the next image in the list and assign it to the label.
Tip: To track what image is shown create a interger member variable. Set it to 0 when starting the animation, increase it in the slot.
Generally, message boxes work like this:
if(ShowMessageBox("Title","Text",MB_YES_NO) == MB_YES)
{
//the user responded yes
}
However, I'm working on a game where I have made the gui system, and when a messagebox is shown, there is still animation happening in the background so I cannot simply block the thread, the animation would stop.
Right now, the way it works is to show the message box, an IMessageHandler* must be provided and it is called with the dialog result.
I'm wondering if I'm overlooking something. Is there a better way to do this that might resemble more how it is usually done. How might other games approach it?
Thanks
There are multiple options, e.g...
Create a View-Model class that the message box reads from (title, message, button text) and writes to (result prior to closing), pass the VM to your message box before displaying it, then read result from VM after close.
(A better technique would to use a command pattern or place an event on the message box instead of passing VM to message box, then within command/event handler update VM).
Use a command pattern or an event to pass result from message box (prior to close) directly to caller (or to view model).
Use a show dialog style call to message box (blocking), however, do that on a separate thread, then write results to a place where main thread can read from.
I am writing a very simple program in C++ that listens to keyboard input, but what I want to output is much more difficult than I expected. For every key I press, I want an image (specific to the key) to appear on the screen. For example, let's say if I press the "O" key, an image of Earth appears on my screen.
What's the best way to achieve this? Thanks!
This is possible with layered windows. I have created a Win32 project as a demo. You can find the code and explanations here.
Basically you have to:
handle the WM_CHAR message and load the appropriate image (from resources or from disk)
create a layered window and display the loaded image in that window
if you want to automatically close the window after an given interval after the last key was pressed you have to create a timer and in the timed procedure destroy the window
Check my link for a solution to your problem.