Results 1 to 5 of 5

Thread: Using QLabel to increase/decrease a Status Bar

  1. #1
    Join Date
    Dec 2015
    Posts
    6
    Qt products
    Qt5
    Platforms
    Windows

    Default Using QLabel to increase/decrease a Status Bar

    Capture.jpg

    Attached is a pic of my StatusBar using QLabel.
    I would like to know how to write the code for increasing or decreasing the white bar inside of the Status Bar. It would be best if you can give me an example of the coding needed to be written.

    Condition:
    • The white bar will increase by one bar at a time whenever a Increase button is pressed.
    • The white bar will decrease by one bar at a time whenever a Decrease button is pressed.
    • All the Statusbar and the 4 white bars are design using QLabel.
    • There are 2 QPushbutton to select the increase or decrease functions.
    Stop resisting and surrender to the dark forces

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Using QLabel to increase/decrease a Status Bar

    If you want to do this with a QLabel, you will have to generate a pixmap every time its content should change and then set the new pixmap.

    However, this looks like a situation where you would want to have a custom widget, that has exactly that visualization.

    - derive from QWidget
    - have a member variable that stores how many sections are filled
    - have two slots, one that increments that value and one that decrements it
    - implement paintEvent() to draw that for and as many sections filled as the member indicates

    Cheers,
    _

  3. #3
    Join Date
    Dec 2015
    Posts
    6
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Using QLabel to increase/decrease a Status Bar

    Hi thank for the reply.
    But do you know how can i go about doing it? Not so sure about doing it.
    Thank you
    Stop resisting and surrender to the dark forces

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Using QLabel to increase/decrease a Status Bar

    Which of the steps have you completed already?

    Cheers,
    _

  5. #5
    Join Date
    Dec 2015
    Posts
    6
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Using QLabel to increase/decrease a Status Bar

    Thanks for the help. I have managed to complete it thanks to my mentor
    Stop resisting and surrender to the dark forces

Similar Threads

  1. Replies: 0
    Last Post: 9th November 2015, 10:04
  2. Replies: 3
    Last Post: 8th July 2010, 07:41
  3. Replies: 1
    Last Post: 29th September 2009, 19:44
  4. How to increase/decrease brightness/sharpness
    By rishiraj in forum Newbie
    Replies: 2
    Last Post: 21st January 2009, 06:25
  5. need to decrease the library size
    By rohan_m_e in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 13th November 2008, 04:38

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
  •  
Qt is a trademark of The Qt Company.