发新话题
打印

Qt一问?

Qt一问?

QT下怎么才能将消息发出?我现在不知道怎么才能发出信号?
我在字符模式下串口接收发送都没问题。但在QT下始终没有运行串口程序也无法弹出窗口?那位高手可以给我讲讲啊      

TOP

这是我程序看看有什么问题,SIGNAL函数由moc自动生成我只是定义了它。为什么程序不运行linSerialttys0() 函数,我的串口信号是一直在发的
Text::Text()
{
  setCaption("Text " VERSION);

  initMenuBar();
  initToolBar();
  initStatusBar();

  initDoc();
  initView();

  initlinSerialttys();
}
void Text::initlinSerialttys() {
        //串口0
        s.OpenDevice("/dev/ttyS0");                //打开串口
        fs = s.GetFileDescriptor();                //获得串口描述符
        serialport = s.GetFileHandle();      //获得文件指针
        //可以采用串口的文件描述符和文件指针来进行各种文件读写操作
        s.SetBits(8, 'N', 1);
        s.SetSpeed(4800);
        s.SetupRaw(1, 0);
       
         connect(this, SIGNAL(signalslinSerialttys0(int)), SLOT(Myslot(int)));
        connect(this, SIGNAL(signalslinSerialttys1(int)), SLOT(Myslot(int)));
}
void Text::Myalarm(int x)
{       
       
        QDialog *groupbox;
        groupbox = new QDialog();
        groupbox -> setMinimumSize( 400, 200);
        groupbox -> setMaximumSize( 400, 200);
         
                 groupbox -> show();
}
void Text::linSerialttys0() {

        select(1, fs, NULL, NULL, NULL);
        while(1) {
                 chRet = fgetc(serialport);
                printf("%c", chRet);
                  emit signalslinSerialttys0(10);
         }
}      

TOP

编译提示是:QT:gdb: -nograb added to command -line options
                    use the -dograb option enforce grabbing      

TOP

发新话题