Qt-interest Archive, March 2008
About Qt Designe4.3.3, can not get the widget's pointer
Message 1 in thread
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:
********************************************************************************
** 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:
#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;///<ini中的频道信息
//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();///<初始调台时的准备工作,load china.ini ...
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
Message 2 in thread
Hi Zhang!
Your constructor have execute "setupUi" by initializate the Widgets, and
later make connect this widgets with your SLOT.
For example:
ScanDlg::ScanDlg( QWidget* parent ) : QDialog(parent)
{
setupUi(this);
connect ( SpinFrom, SIGNAL ( valueChanged(int) ), this, SLOT (
on_SpinFrom_valueChanged(int) ) );
...
...
...
...
}
Salu2.
Zhang escribiÃ:
> 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:
> ********************************************************************************
> ** 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:
>
> #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;///<iniäçééäæ
>
>
> //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();///<ååèåæçåååä,load china.ini ...
> 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
>
--
[ signature omitted ]
Message 3 in thread
Will someone please clue me in as to what is wrong with the code snip-it
below. I'm trying to print out the Greek omega symbol (as in ohms), but
its not printing anything.
QTextStream out (stdout);
out << QChar (0x2126) << endl;
If I use the c library version I can get this to work, but I'd like to
stick with a Qt solution.
cout << "\u2126" << endl;
Thanks
Message 4 in thread
Does your terminal/console support Unicode?
On Mon, 24 Mar 2008 23:18:24 +0300, Joaquin Luna <Joaquin.Luna@xxxxxxxx>
wrote:
> Will someone please clue me in as to what is wrong with the code snip-it
> below. I'm trying to print out the Greek omega symbol (as in ohms), but
> its not printing anything.
>
> QTextStream out (stdout);
>
> out << QChar (0x2126) << endl;
>
> If I use the c library version I can get this to work, but I'd like to
> stick with a Qt solution.
>
> cout << "\u2126" << endl;
>
> Thanks
--
[ signature omitted ]
Message 5 in thread
On Monday 24 March 2008 21:18:24 Joaquin Luna wrote:
> Will someone please clue me in as to what is wrong with the code snip-it
> below. I'm trying to print out the Greek omega symbol (as in ohms), but
> its not printing anything.
nothing or garbage?
if it prints nothing, you didn't initalise the text codecs yet (just construct
a QApplication)
if it prints garbage (two characters instead of one) then you use cstrings and
your source codec isnt Latin1. (Qt assumes you are writing all source files
in latin1, reported a bug but got ignored)
you can either
void QTextCodec::setCodecForCStrings ( QTextCodec * codec ) [static]
or just use trUtf8() instead of tr() or fromUtf8(). you should never use raw
cstrings anyway.
#include <QTextStream>
#include <QApplication>
int main(int argc, char** argv)
{
QApplication app(argc,argv);
QTextStream(stdout) << QChar(0x2126)<<QObject::trUtf8("\u2126")<<endl;
}
--
[ signature omitted ]
Message 6 in thread
Hi,
> Will someone please clue me in as to what is wrong with the code snip-it
> below. I’m trying to print out the Greek omega symbol (as in ohms), but
> its not printing anything.
>
>
>
> QTextStream out (stdout);
>
> out << QChar (0x2126) << endl;
Note that 2126 is the "OHM SIGN":
http://www.fileformat.info/info/unicode/char/2126/index.htm
while the "GREEK CAPITAL LETTER OMEGA" is 03A9:
http://www.fileformat.info/info/unicode/char/03a9/index.htm
It could be that the font used by the console does not have support for
character 2126. On which exact platform does this happen?
--
[ signature omitted ]