Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Extra Double Quotes ("") retrieves from objectName.
Forum Updated to NodeBB v4.3 + New Features

Extra Double Quotes ("") retrieves from objectName.

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hareen Laks
    wrote on last edited by
    #1

    Hi,

    I'm beginner to the Qt and while studying the Qt course material I got a problem.

    I have 3 files.

    1. valueobject.h

    @#ifndef VALUEOBJECT_H
    #define VALUEOBJECT_H

    #include <QObject>

    class ValueObject : public QObject
    {
    Q_OBJECT

    public:
    explicit ValueObject(QObject *parent = 0);
    virtual ~ValueObject();

    };

    #endif // VALUEOBJECT_H@

    1. valueobject.cpp

    @#include "valueobject.h"
    #include <QDebug>

    ValueObject::ValueObject(QObject *parent) :
    QObject(parent)
    {
    qDebug() << "ValueObject constructed";
    }

    ValueObject::~ValueObject()
    {
    qDebug() << "ValueObject" << this->objectName() << "destructed";
    }@

    3.main.cpp

    #include "valueobject.h"

    @#include <QDebug>
    #include <QFile>

    int main(int argc, char *argv[])
    {
    ValueObject o;
    o.setObjectName("root");

    return 0;
    

    }@

    When I run the program I got the result as

    ValueObject constructed
    ValueObject "root" destructed

    My problem is how extra "" appears in both sides of word 'root'?

    I also tried

    @QString root ="root"
    o.setObjectName(root);@

    but result is same.

    Thanks in advance.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      chris17
      wrote on last edited by
      #2

      thats how QDebug handles QStrings.
      To get it without the double quotes you can do the following:
      @qDebug() << "ValueObject" << this->objectName().toLatin1().data() << "destructed";
      @

      1 Reply Last reply
      0
      • H Offline
        H Offline
        Hareen Laks
        wrote on last edited by
        #3

        @ chris17,

        Thank you very much..

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved