Results 1 to 5 of 5

Thread: Label

  1. #1

    Default Label

    I want to put in a picture in my QT application.
    I made an empty label and called Label_pic
    when I go in manwindow.cpp and write
    "ui> Label_pic-> setPixmap (pix) for i an error where it says" no member 'label_pic' in 'ui :: mainwindow "Label.jpgfeil.jpg

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    3,973
    Thanks
    232
    Thanked 627 Times in 617 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Label

    Your screenshots are too small to read. Please post the ACTUAL CODE, not screenshots so we can read what you are doing. Put your code inside CODE tags (see my signature below).
    <=== 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

    Default Re: Label

    Qt Code:
    1. QPixmap pix("C:\QT Nyeveier/Nyeveier.png");
    2. ui->label_Pic->setPixmap(pix)
    To copy to clipboard, switch view to plain text mode 

    and then i get this error: no member named 'label_Pic' in 'Ui::MainWindow'

    Qt Code:
    1. <widget class="QLabel" name="label_Pic">
    2. <property name="geometry">
    3. <rect>
    4. <x>20</x>
    5. <y>20</y>
    6. <width>151</width>
    7. <height>221</height>
    8. </rect>
    9. </property>
    10. <property name="text">
    11. <string/>
    12. </property>
    To copy to clipboard, switch view to plain text mode 

    This is from my mainwindow.ui

  4. #4
    Join Date
    Jul 2012
    Posts
    223
    Thanks
    18
    Thanked 14 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Label

    Manually run qmake (rightclick on project -> run qmake) and re-compile the project a few times. Sometimes there are hickups.

  5. #5
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    3,973
    Thanks
    232
    Thanked 627 Times in 617 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Label

    Manually run qmake
    Yes, I agree. I don't see anything wrong with the code or ui file, and support for "png" format is built-in and does not require a separate driver. So probably your ui file did not get compiled after you added or changed the name of the QLabel item.

    Also, make sure when you use a backslash ("") in string that you "escape" it: "C:\\folder\\filename.png" If you don't it will treat a "\f" as a special character and the actual filename string that gets passed to setPixmap() will be incorrect.
    Last edited by d_stranz; 5th March 2019 at 18:30.
    <=== 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. QwtAnalogClock without label
    By QTim in forum Qwt
    Replies: 3
    Last Post: 14th March 2019, 12:06
  2. How to add label in speedometer
    By cooper in forum Qwt
    Replies: 3
    Last Post: 1st August 2011, 08:31
  3. how to set fontsize for label?
    By BalaQT in forum Qt Programming
    Replies: 3
    Last Post: 18th September 2009, 17:02
  4. QCheckbox label
    By drkbkr in forum Qt Programming
    Replies: 1
    Last Post: 19th January 2009, 19:58
  5. label
    By mickey in forum Qt Programming
    Replies: 10
    Last Post: 8th June 2006, 18:58

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.