Results 1 to 2 of 2

Thread: QTreeWidget ui was not declared

  1. #1
    Join Date
    Jul 2018
    Posts
    7
    Qt products
    Qt4 Qt5
    Platforms
    Windows Android

    Question QTreeWidget ui was not declared

    hey this is my code and It says that 'ui' was not declared

    Dialog:ialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui:ialog)
    {
    ui->setupUi(this);

    ui->treeWidget->setColumnCount(2); //and it says there is a problem there too about ->treeWidget must point to class/struct/pointer
    AddRoot("hello", "world");
    }

    Dialog::~Dialog()
    {
    delete ui;
    }


    void AddRoot(QString name, QString description)
    {
    QTreeWidgetItem *itm = new QTreeWidgetItem (ui->treeWidget);

    itm->setText(0, name);
    itm->setText(1, description);
    ui->treeWidget->addTopLevelItem(itm);

    }

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QTreeWidget ui was not declared

    Did you add a QTreeWidget class instance into your Dialog.ui file named "treeWidget" when you used Qt Designer to define your dialog's UI?

    And use CODE tags when posting source code. See my signature block 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.

Similar Threads

  1. Replies: 2
    Last Post: 12th April 2016, 00:38
  2. Replies: 0
    Last Post: 21st October 2013, 10:16
  3. Where is the connection declared?
    By szisziszilvi in forum Newbie
    Replies: 7
    Last Post: 24th August 2011, 10:15
  4. ui not declared in scope
    By steve.bush in forum Newbie
    Replies: 5
    Last Post: 19th March 2011, 09:58
  5. Replies: 2
    Last Post: 17th March 2008, 13:53

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.