+ Reply to Thread
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
    3,699
    Thanks
    212
    Thanked 566 Times in 556 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    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.

+ Reply to Thread

Similar Threads

  1. Replies: 2
    Last Post: 11th April 2016, 23:38
  2. Replies: 0
    Last Post: 21st October 2013, 09:16
  3. Where is the connection declared?
    By szisziszilvi in forum Newbie
    Replies: 7
    Last Post: 24th August 2011, 09:15
  4. ui not declared in scope
    By steve.bush in forum Newbie
    Replies: 5
    Last Post: 19th March 2011, 08:58
  5. Replies: 2
    Last Post: 17th March 2008, 12: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