Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt show() in boost coroutine function
Forum Updated to NodeBB v4.3 + New Features

Qt show() in boost coroutine function

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 391 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    iamfly
    wrote on last edited by
    #1

    I was trying to show a widget in boost coroutine, and called show() crashed.
    Boost version is 1.83.0, Qt version is 5.15.2

    Here is my code:

    QFile uiFile = QFile(QString("a.ui"));
    if (!uiFile.open(QIODevice::ReadOnly))
    {
    	return;
    }
    QUiLoader loader;
    
    QWidget* pWidget = loader.load(&uiFile);
    pWidget->show();
    uiFile.close();
    

    Here is call stack:
    ab936ce3-23c6-4ea4-ac4f-cab971d32b57-image.png

    613675ce-be24-45d5-97a7-edfe2446c1e4-image.png

    Christian EhrlicherC 1 Reply Last reply
    0
    • I iamfly

      I was trying to show a widget in boost coroutine, and called show() crashed.
      Boost version is 1.83.0, Qt version is 5.15.2

      Here is my code:

      QFile uiFile = QFile(QString("a.ui"));
      if (!uiFile.open(QIODevice::ReadOnly))
      {
      	return;
      }
      QUiLoader loader;
      
      QWidget* pWidget = loader.load(&uiFile);
      pWidget->show();
      uiFile.close();
      

      Here is call stack:
      ab936ce3-23c6-4ea4-ac4f-cab971d32b57-image.png

      613675ce-be24-45d5-97a7-edfe2446c1e4-image.png

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by Christian Ehrlicher
      #2

      @iamfly You must not access gui elements from outside the main thread.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2
      • I Offline
        I Offline
        iamfly
        wrote on last edited by
        #3

        @Christian-Ehrlicher

        You mean no possible to access qt widgets outside mainthread? Or how about use qt coroutine?

        jsulmJ 1 Reply Last reply
        0
        • I iamfly

          @Christian-Ehrlicher

          You mean no possible to access qt widgets outside mainthread? Or how about use qt coroutine?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @iamfly said in Qt show() in boost coroutine function:

          You mean no possible to access qt widgets outside mainthread?

          Yes. Do not modify UI outside of the main thread. Other threads can emit signals to trigger changes in the UI and pass data to it. In main thread you subscribe to these signals and modify the UI.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          I 1 Reply Last reply
          1
          • jsulmJ jsulm

            @iamfly said in Qt show() in boost coroutine function:

            You mean no possible to access qt widgets outside mainthread?

            Yes. Do not modify UI outside of the main thread. Other threads can emit signals to trigger changes in the UI and pass data to it. In main thread you subscribe to these signals and modify the UI.

            I Offline
            I Offline
            iamfly
            wrote on last edited by
            #5

            @jsulm Thanks, i will try that way.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved