qt 信号和槽不是多线程

MainWindow::MainWindow(QWidget *parent)
  : QMainWindow(parent)
  , ui(new Ui::MainWindow)
{
  ui->setupUi(this);
  connect(this,&MainWindow::singalFun,this,[=]{
    int i =20;
    while(1){
      std::cout<<"singalFun \n";
      i--;
    }
  });
   acquisition_thread = new std::thread(&MainWindow::printThread, this);
  emit singalFun();
  int i =20;
  while(1){
    std::cout<<"main \n";
    i--;
  }
}

MainWindow::~MainWindow()
{
  delete ui;
}

void MainWindow::printThread()
{
  int i =20;
  while(1){
    std::cout<<"printThread \n";
    i--;
  }
}

打印的结果为

printThread  singalFun  交替打印  但是没有打印 main

你可能感兴趣的:(qt,qt,c++)