Results 1 to 6 of 6

Thread: How to check if QLabel is empty??

  1. #1
    Join Date
    Sep 2015
    Posts
    23
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default How to check if QLabel is empty??

    Hi,

    I have a gridlayout and in it are 9 QLabels where I emit QImages and display them.

    I have to check if QLabel is free and them emit QImage so it is displayed.
    How do I check if QLabel is already used by somebody so I can go to other QLabel.

    this is very helpful in doing dynamic Layouts.

    Regards

  2. #2
    Join Date
    May 2015
    Posts
    66
    Thanks
    10
    Thanked 17 Times in 17 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to check if QLabel is empty??

    QLabel:: pixmap() returns 0 if no pixmap is set on it.

  3. #3
    Join Date
    Sep 2015
    Posts
    23
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to check if QLabel is empty??

    Hi Vikram

    Many signals are mapped to One slot . In slot function, I decide the empty label like this:

    if(ui->label->pixmap == 0)
    ui->label->setPixMap(......image 1..);
    else if (if(ui->label_2->pixmap == 0)
    ui->label_2->setPixMap(...... image 2..);

    Both the images are displayed on first label only. ie ui->label.
    I want the second image to be displayed on the ui->label_2.


    I don't display the whole Image on label at once. I display them strip by strip ie blocks of 20*768 size strips.

    Any idea?

    Thanks for the reply.

  4. #4
    Join Date
    May 2015
    Posts
    66
    Thanks
    10
    Thanked 17 Times in 17 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to check if QLabel is empty??

    It should be label->pixmap(). Without parenthesis you are checking the function pointer which isn't 0.

  5. The following user says thank you to Vikram.Saralaya for this useful post:

    ganapathi (9th December 2015)

  6. #5
    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: How to check if QLabel is empty??

    And you probably want to check isNull() on the returned pixmap.

    Cheers,
    _

  7. The following user says thank you to anda_skoa for this useful post:

    ganapathi (9th December 2015)

  8. #6
    Join Date
    Sep 2015
    Posts
    23
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to check if QLabel is empty??

    Quote Originally Posted by Vikram.Saralaya View Post
    It should be label->pixmap(). Without parenthesis you are checking the function pointer which isn't 0.
    Thanks vikram....it worked.

Similar Threads

  1. [PyQt4] check if value of QLabel changed
    By ja.heller in forum Newbie
    Replies: 2
    Last Post: 30th April 2014, 02:51
  2. How to check if the QListWidget is empty ?
    By zero-n in forum Newbie
    Replies: 2
    Last Post: 24th July 2010, 14:02
  3. Replies: 1
    Last Post: 29th September 2009, 20:44
  4. empty pixmap as a QLabel
    By tommy in forum Qt Programming
    Replies: 16
    Last Post: 11th December 2007, 22:15
  5. remove directory empty or not empty
    By raphaelf in forum Newbie
    Replies: 12
    Last Post: 27th October 2006, 08:30

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.