Results 1 to 5 of 5

Thread: how to initialize label through code

  1. #1
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default how to initialize label through code

    hi am using Atmel SAMA5D3 platform in that am using Application QT.I want ot define label,i used code
    QLabel *l=new QLabel(this);
    l->setText("welcome to Atmel");
    l->show();
    it shows an some buiild errors.can any one give me suggestion for this.
    Thanks in advance

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,391
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: how to initialize label through code

    it shows an some buiild errors.can any one give me suggestion for this
    No, until you show us "some build errors".
    Qt Code:
    1. QLabel *l=new QLabel(this);
    To copy to clipboard, switch view to plain text mode 
    Is "this" a pointer to QWidget-based object ? My guess is that you have this code in "main()" and there is no valid "this" pointer.
    Why don't you just show full code and build errors in the first post ?

  3. #3
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to initialize label through code

    k stampede
    widget.cpp
    Qt Code:
    1. #include "widget.h"
    2. #include "ui_widget.h"
    3. #include<QtGui>
    4. Widget::Widget(QWidget *parent) :
    5. QWidget(parent),
    6. ui(new Ui::Widget)
    7. {
    8. QLabel *l=new QLabel(this);
    9. l->setText("welcome to Atmel");
    10. l->show();
    11. ui->setupUi(this);
    12. }
    13.  
    14. Widget::~Widget()
    15. {
    16. delete ui;
    17. }
    To copy to clipboard, switch view to plain text mode 
    error:

    make: Circular check <- first dependency dropped.

    Quote Originally Posted by stampede View Post
    No, until you show us "some build errors".
    Qt Code:
    1. QLabel *l=new QLabel(this);
    To copy to clipboard, switch view to plain text mode 
    Is "this" a pointer to QWidget-based object ? My guess is that you have this code in "main()" and there is no valid "this" pointer.
    Why don't you just show full code and build errors in the first post ?
    Last edited by wysota; 17th February 2015 at 09:43. Reason: missing [code] tags

  4. #4
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,391
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: how to initialize label through code

    make: Circular check <- first dependency dropped.
    It is not related to the C++ code. Did you try to edit the makefile by hand ?
    Can we see your project .pro file ?

  5. #5
    Join Date
    Nov 2014
    Location
    Chennai
    Posts
    160
    Thanks
    65
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to initialize label through code

    sure stampede
    check.pro:
    #-------------------------------------------------
    #
    # Project created by QtCreator 2015-02-10T14:46:25
    #
    #-------------------------------------------------

    QT += core gui
    linux-*{
    target.path=/home/root
    INSTALLS+=target
    }


    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = check
    TEMPLATE = app


    SOURCES += main.cpp\
    widget.cpp

    HEADERS += widget.h

    FORMS += widget.ui
    Quote Originally Posted by stampede View Post
    It is not related to the C++ code. Did you try to edit the makefile by hand ?
    Can we see your project .pro file ?
    Last edited by iswaryasenthilkumar; 17th February 2015 at 14:24.

Similar Threads

  1. Could not initialize OLE weirdness
    By stevey in forum Qt Programming
    Replies: 1
    Last Post: 2nd August 2013, 22:20
  2. How to Un- Initialize the drive in xp?
    By Gokulnathvc in forum Newbie
    Replies: 3
    Last Post: 13th May 2011, 00:45
  3. Problem with code (probably repaintinng label)
    By hakermania in forum Newbie
    Replies: 2
    Last Post: 8th January 2011, 14:58
  4. Initialize a QTreeWidgetItemIterator
    By Daniel Dekkers in forum Qt Programming
    Replies: 0
    Last Post: 12th April 2010, 13:35
  5. Better way to initialize QVector
    By lyucs in forum Newbie
    Replies: 3
    Last Post: 25th August 2009, 09:25

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.