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. Why code completion does not work, what's wrong on my code?
Forum Updated to NodeBB v4.3 + New Features

Why code completion does not work, what's wrong on my code?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 809 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.
  • A Offline
    A Offline
    Arrandale
    wrote on last edited by
    #1

    @#include <QObject>
    #include <QStringList>

    class MyClass : public QObject
    {
    Q_OBJECT

    public:
    explicit MyClass(QObject *parent = 0);
    explicit MyClass(const MyClass &myclass, QObject *parent = 0);
    MyClass &operator=(const MyClass &myclass);
    QString &operator[](int i);

    public slots:
    void append(const QString &name);

    private:
    QStringList m_name;

    };

    //---------------------------------------------------------

    MyClass::MyClass(QObject *parent) :
    QObject(parent)
    {
    }

    MyClass::MyClass(const MyClass &myclass, QObject *parent) :
    QObject(parent)
    {
    *this = myclass;
    }

    MyClass &MyClass::operator =(const MyClass &myClass)
    {
    m_name = myClass.m_name;
    return *this;
    }

    QString &MyClass::operator [](int i)
    {
    return m_name[i];
    }

    void MyClass::append(const QString &name)
    {
    m_name.append(name);
    }

    //---------------------------------------------------------

    #include "mainwindow.h"
    #include "myclass.h"

    MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    {
    MyClass a;
    MyClass b(a);
    b[0]. // where code completion does not work.

    MyClass c;
    c = a;
    c[0]. // work fine.
    }@

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      Are you taking about auto complete in QtCreator IDE ? May be it is not able to identify 'b' as object due to default parameter. Create object with correct number of parameter in constructor

      e.g MyClass b(a,0);

      Then it start showing it. May be bug in QtCreator iDE.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Arrandale
        wrote on last edited by
        #3

        Yes, it's in Qt Creator.
        If provide with full number of parameter it's work fine.
        I just worry about my code what I do wrong why IDE can't detect.
        So it's just a bug?

        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