Results 1 to 2 of 2

Thread: Carousel with QLabels

  1. #1
    Join Date
    Sep 2021
    Qt products

    Default Carousel with QLabels

    I would like to create carousel with QLabels. Nothing special. Each QLabel will contain only text. I'm not using QML.

    Just a quick qt designer example. QLabels will be added/created programmatically, not in designer.

    My first idea was to add all QLabels in QHBoxLayout and us hide()/show() to create carousel like view.

    Any ideas or suggestions are welcome.

  2. #2
    Join Date
    Jan 2008
    Alameda, CA, USA
    Thanked 864 Times in 851 Posts
    Qt products

    Default Re: Carousel with QLabels

    Any ideas or suggestions are welcome.
    Use the Flow Layout from this example. Add your layout into a QWidget and put the QWidget into a QScrollArea. If you handle the size hint of the widget correctly, the scrolling should work automatically. If you don't like the scrollbar at the bottom, you can hide the scrollbars, make an h box with your own arrows at left and right (as you show in your screenshot) and the flow layout in the middle, and handle the scrolling manually via button clicks. Even better would be the ability to grab a label and move the whole thing left and right.

    Hiding and showing widgets in an h box will not give a very nice visual experience. As you hide or show widgets, all of the others will appear to jump to new positions as the layout is recalculated. A better experience would be a smooth scrolling from side to side.
    <=== 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.

Similar Threads

  1. 3D carousel list without QML
    By Charvi in forum Qt Programming
    Replies: 2
    Last Post: 28th August 2012, 14:53
  2. Qt Quick, QML Carousel animation
    By napajejenunedk0 in forum Qt Quick
    Replies: 0
    Last Post: 25th August 2011, 12:58
  3. How to show QLabels
    By Pavel Abrosimov in forum Qt Programming
    Replies: 24
    Last Post: 9th July 2009, 10:39
  4. Dynamic QLabels
    By rajeshs in forum Qt Programming
    Replies: 3
    Last Post: 30th May 2008, 12:26
  5. QSpinBox or QLabels
    By ToddAtWSU in forum Qt Programming
    Replies: 10
    Last Post: 27th November 2007, 21:10


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.