Problem with Qt Object names

I have created the widegts in the form editor and changed their object names. I then save the form and then run the code.
I get the error
error: 'primaryOrderComboBox' was not declared in this scope
as well as for all other objects.

How can i fix this scope issue. Thanks

here is my code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "sortdialog.h"
#include "ui_sortdialog.h"

SortDialog::SortDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::SortDialog)
{
    ui->setupUi(this);
    secondaryGroupBox->hide();
    tertiaryGroupBox->hide();
    layout()->setSizeConstraint(QLayout::SetFixedSize);
    setColumnRange('A','Z');
}
void SortDialog::setColumnRange(QChar first, QChar last)
{
    primaryColumnComboBox->clear();
    secondaryColumnComboBox->clear();
    tertiaryColumnComboBox->clear();

    primaryColumnComboBox->addItem("None");
    primaryOrderComboBox->addItem("Ascending");
    primaryOrderComboBox->addItem("Descending");

    secondaryColumnComboBox->addItem("None");
    tertiaryColumnComboBox->addItem("None");

    primaryColumnComboBox->setMinimumSize(
                secondaryColumnComboBox->sizeHint());
    QChar ch = first;
    while(ch <= last)
    {
        primaryColumnComboBox->addItem(ch);
        secondaryColumnComboBox->addItem(ch);
        tertiaryColumnComboBox->addItem(ch);
        ch = ch.unicode() + 1;
    }
}
SortDialog::~SortDialog()
{
    delete ui;
}


and the header file

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef SORTDIALOG_H
#define SORTDIALOG_H

#include <QDialog>

namespace Ui {
class SortDialog;
}

class SortDialog : public QDialog
{
    Q_OBJECT
    
public:
    explicit SortDialog(QWidget *parent = 0);
    void setColumnRange(QChar first, QChar last);
    ~SortDialog();
    
private:
    Ui::SortDialog *ui;
};

#endif // SORTDIALOG_H 
When you use the form editor any changes are made in the ui file and you have to tell it look there.
1
2
3
4
5
6
7
primaryOrderComboBox->addItem("Ascending");
primaryOrderComboBox->addItem("Descending");

// For example should be

ui->primaryOrderComboBox->addItem("Ascending");
ui->primaryOrderComboBox->addItem("Descending");

If you had created them in the header file, what you have would work.
Thank you.
Topic archived. No new replies allowed.