I'm new to qt designer. I wrote a dialog with qt designer, but I found that when I tried to control the widget in the .ui I only got an empty pointer, can anyone give me some advise? Thanks.
here is the ui_scan.h generated by uic:
|
Source 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
********************************************************************************
** Form generated from reading ui file 'scan.ui'
**
** Created: Fri Mar 14 17:01:04 2008
** by: Qt User Interface Compiler version 4.3.3
**
** WARNING! All changes made in this file will be lost when recompiling ui file!
********************************************************************************/
#ifndef UI_SCAN_H
#define UI_SCAN_H
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QDialog>
#include <QtGui/QHBoxLayout>
#include <QtGui/QLabel>
#include <QtGui/QProgressBar>
#include <QtGui/QPushButton>
#include <QtGui/QSpacerItem>
#include <QtGui/QSpinBox>
#include <QtGui/QTextBrowser>
#include <QtGui/QVBoxLayout>
#include <QtGui/QWidget>
class Ui_ScanDlg
{
public:
QWidget *layoutWidget;
QVBoxLayout *vboxLayout;
QLabel *label;
QHBoxLayout *hboxLayout;
QLabel *label_3;
QSpinBox *SpinFrom;
QLabel *label_4;
QSpinBox *SpinTo;
QSpacerItem *spacerItem;
QPushButton *ButtonScan;
QProgressBar *ProgressScan;
QLabel *label_2;
QTextBrowser *TextBroScanResult;
void setupUi(QDialog *ScanDlg)
{
if (ScanDlg->objectName().isEmpty())
ScanDlg->setObjectName(QString::fromUtf8("ScanDlg"));
ScanDlg->resize(354, 453);
layoutWidget = new QWidget(ScanDlg);
layoutWidget->setObjectName(QString::fromUtf8("layoutWidget"));
layoutWidget->setGeometry(QRect(20, 20, 311, 401));
vboxLayout = new QVBoxLayout(layoutWidget);
vboxLayout->setObjectName(QString::fromUtf8("vboxLayout"));
vboxLayout->setContentsMargins(0, 0, 0, 0);
label = new QLabel(layoutWidget);
label->setObjectName(QString::fromUtf8("label"));
vboxLayout->addWidget(label);
hboxLayout = new QHBoxLayout();
hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
label_3 = new QLabel(layoutWidget);
label_3->setObjectName(QString::fromUtf8("label_3"));
hboxLayout->addWidget(label_3);
SpinFrom = new QSpinBox(layoutWidget);
SpinFrom->setObjectName(QString::fromUtf8("SpinFrom"));
SpinFrom->setValue(35);
hboxLayout->addWidget(SpinFrom);
label_4 = new QLabel(layoutWidget);
label_4->setObjectName(QString::fromUtf8("label_4"));
hboxLayout->addWidget(label_4);
SpinTo = new QSpinBox(layoutWidget);
SpinTo->setObjectName(QString::fromUtf8("SpinTo"));
SpinTo->setValue(39);
hboxLayout->addWidget(SpinTo);
spacerItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
hboxLayout->addItem(spacerItem);
ButtonScan = new QPushButton(layoutWidget);
ButtonScan->setObjectName(QString::fromUtf8("ButtonScan"));
hboxLayout->addWidget(ButtonScan);
vboxLayout->addLayout(hboxLayout);
ProgressScan = new QProgressBar(layoutWidget);
ProgressScan->setObjectName(QString::fromUtf8("ProgressScan"));
ProgressScan->setValue(0);
vboxLayout->addWidget(ProgressScan);
label_2 = new QLabel(layoutWidget);
label_2->setObjectName(QString::fromUtf8("label_2"));
vboxLayout->addWidget(label_2);
TextBroScanResult = new QTextBrowser(layoutWidget);
TextBroScanResult->setObjectName(QString::fromUtf8("TextBroScanResult"));
vboxLayout->addWidget(TextBroScanResult);
label_3->setBuddy(SpinFrom);
label_4->setBuddy(SpinTo);
label_2->setBuddy(TextBroScanResult);
retranslateUi(ScanDlg);
QObject::connect(ButtonScan, SIGNAL(clicked()), ProgressScan, SLOT(reset()));
QMetaObject::connectSlotsByName(ScanDlg);
} // setupUi
void retranslateUi(QDialog *ScanDlg)
{
ScanDlg->setWindowTitle(QApplication::translate("ScanDlg", "Scan Channels", 0, QApplication::UnicodeUTF8));
label->setText(QApplication::translate("ScanDlg", "Scan Range:", 0, QApplication::UnicodeUTF8));
label_3->setText(QApplication::translate("ScanDlg", "From:", 0, QApplication::UnicodeUTF8));
label_4->setText(QApplication::translate("ScanDlg", "To:", 0, QApplication::UnicodeUTF8));
ButtonScan->setText(QApplication::translate("ScanDlg", "Scan", 0, QApplication::UnicodeUTF8));
label_2->setText(QApplication::translate("ScanDlg", "Available Channels:", 0, QApplication::UnicodeUTF8));
Q_UNUSED(ScanDlg);
} // retranslateUi
};
namespace Ui {
class ScanDlg: public Ui_ScanDlg {};
} // namespace Ui
#endif // UI_SCAN_H
/////////////////////////////////////////////////////////////////////////////#########################################3/
|
and here is the scan.h wrote by myself:
|
Source 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
42
43
44
45
|
#ifndef __SCAN_H__
#define __SCAN_H__
#include "ui_scan.h"
//class QTextBrowser;
//class QPushButton;
//class QSpinBox;
//class QProgressBar;
#include "mypsiscanner.h"
typedef struct tagCHAN_Info
{
//int m_nChanNum;
int ChanFreq;
int SymbolRate;
int QAM;
}CHAN_Info;///
//class ScanDlg : public QDialog, public Ui::ScanDlg
class ScanDlg : public QDialog, public Ui::ScanDlg
{
Q_OBJECT
public :
//ScanDlg( QWidget* parent = 0, Qt::WindowFlags f = 0 );
ScanDlg( QWidget* parent = 0 );
~ScanDlg();
int scanBetween(int startchan, int endchan);///
int scanOneChannel(int freq, int byrate);
int prepareScan();///<
signals:
private slots:
// void updateRange();
void on_SpinFrom_valueChanged(/*int value*/);//@#@#@if I use another function name here(do not use the setupUi to connect this SLOT to SpinFrom automatically), I also can only get empty pointers( can not control SpinFrom, SpinTo, ButtonScan and any other widgets designed in the Qt Designer)
void on_SpinFrom_valueChanged(/*int value*/);
void on_ButtonScan_clicked();
void refreshScanResult();
private:
CHAN_Info m_aChanIni[100];//chan 1 ~ chan 100
Ui::ScanDlg ui;
};
#endif
////////////////////////////////////////##################################33333
|
now the problem is that there are some make error like: scan.h:36:
error:'void ScanDlg::on_SpinFrom_valueChanged()' can not be overrided
if I use another SLOT function name here(do not use the setupUi to connect the on_SpinFrom_valueChanged() SLOT to SpinFrom automatically), it also doesn't work, I can not control SpinFrom, SpinTo, ButtonScan and any other widgets designed in the Qt Designer, these pointers are all NULL
Can anyone give me some advise? Thanks
This post has been edited 1 times, last edit by "happylife" (Mar 14th 2008, 10:53am)