Results 1 to 9 of 9

Thread: Create images slideshow in c++

  1. #1
    Join Date
    Sep 2019
    Posts
    5
    Qt products
    Qt5

    Default Create images slideshow in c++

    I want to Devlope slideshow of images available in qrc file when I click on left key and right key it will show next image . Can anyone give some idea for that or any reference file to me that help me to create this?

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,229
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Create images slideshow in c++

    The usual way to load and display images is using a QLabel to display the image and QPixmap or QImage to load the image from the resource file using the "qrc:///path-to-resource/image-file.png" or ":/path-to-resource/image-file.png" resource file name conventions.

    To change the pictures, you will need to implement an event handler for QWidget::keyPressEvent() or QWidget::keyReleaseEvent(), looking for QKeyEvent::key() values equal to Qt::Key_Left or Qt::Key_Right.

    The easiest way is to derive a new class from QLabel and override the keyPressEvent() or keyReleaseEvent(). In your event handler, you load the next image from the qrc file and display it using QLabel::setPixmap().

    I am not going to give you source code. This sounds a lot like a homework project, and the goal of homework is to force you to learn how to solve your own programming problems.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Sep 2019
    Posts
    5
    Qt products
    Qt5

    Default Re: Create images slideshow in c++

    When I use key press(QKeyEvent *event) and then inside I use if else to check key using event->key() value equal to Qt:Key_Left or Right and i increase value of I and then I use stringlist to store more image paths and show in label using this statement


    Ui->label->setPixmap(image paths[ยก]) but when I run and press key my application forcefully close

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,229
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Create images slideshow in c++

    but when I run and press key my application forcefully close
    The you need to make a Debug version of your program, run it in the debugger, and find out what is causing the crash. In the one line of code you posted, I see at least four things that could cause a crash:

    1 - Does "Ui" contain a valid pointer?
    2 - Does "label" contain valid pointer, and does it point to a QLabel instance?
    3 - Does "i" have a valid value?
    4 - Does "image paths[i]" contain a valid path name?
    5 - Did the call to setPixmap() succeed?

    Your code doesn't check for any errors, and it assumes everything will work perfectly.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  5. #5
    Join Date
    Sep 2019
    Posts
    5
    Qt products
    Qt5

    Default Re: Create images slideshow in c++

    What is means sigabrt signal that cause my application crash?

  6. #6
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    503
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Create images slideshow in c++

    Hi, sigabrt is for example used by the C library to notify your program of critical error, e.g. problems with the heap.

    Ginsengelf

  7. #7
    Join Date
    Sep 2019
    Posts
    5
    Qt products
    Qt5

    Default Re: Create images slideshow in c++

    Can anyone tell how to access stringlist where I save all path of my images.
    Qt Code:
    1. QPixmap slide = QPixmap(d->imagePaths[d->currentSlide]);
    2. }
    To copy to clipboard, switch view to plain text mode 
    In this code this line will create problem and give sigabrt signal. Can you please tell how to access element in list?
    Last edited by Rd1912; 20th September 2019 at 08:28.

  8. #8
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,229
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Create images slideshow in c++

    If you want help, you are going to have to show more than one line of code. Show the code that gives the definitions (data types) for "d", "imagePaths", and "currentSlide" and show how you are loading these variables with values. In other words, copy enough of your actual code that we could study it and try to find your error.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  9. #9
    Join Date
    Sep 2019
    Posts
    5
    Qt products
    Qt5

    Default Re: Create images slideshow in c++

    i able to detect error that lead crash.it is because i (for list) not getting valid value. now it works fine.

Similar Threads

  1. How To Create Simple Images Slider?
    By Ade Malsasa Akbar in forum Newbie
    Replies: 5
    Last Post: 1st June 2013, 09:42
  2. Replies: 1
    Last Post: 6th December 2012, 21:32
  3. Avoid flicker during slideshow with QPropertyAnimation
    By RazZziel in forum Qt Programming
    Replies: 4
    Last Post: 6th March 2012, 18:18
  4. How to apply the turnover effect to the image slideshow
    By Sirisha in forum Qt Programming
    Replies: 2
    Last Post: 22nd November 2011, 08:16
  5. Replies: 1
    Last Post: 20th January 2011, 11:26

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.