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. Problem after iterate through a midsubwindowlist
Forum Updated to NodeBB v4.3 + New Features

Problem after iterate through a midsubwindowlist

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 340 Views 1 Watching
  • 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.
  • P Offline
    P Offline
    pixbyte
    wrote on last edited by pixbyte
    #1

    I hope I get some help into a QT problem I have. I have a App with mdiArea. Everything works fine, but I have one issue:

    If I open first window1 then window2, everything works well. If I click now again on the button to create window2, I iterate through the mdisubwindowlist.

       foreach (QMdiSubWindow *window, mdiArea->subWindowList()) {
            MdiChildBase *mdiChild = qobject_cast<MdiChildBase *>(window->widget());
            if (nullptr != mdiChild){
                qDebug("Ist Childbase");
                RuleManager::ProjectType tProject = mdiChild->GetProjectType();
                if(tProject == RuleManager::TYPE_PROJECT_DISKINFO){
                    qDebug("Ist Diskinfo");
                    if(strDriveName.at(0)==mdiChild->getBurnDrive().at(0)){
                        qDebug("same window");
                        mdiChild->activateWindow();
                        return;
                    }
                }else{
                    qDebug("Nicht Diskinfo");
                }
            }
        }
    

    After the code iterate through the subwindowlist, I get the problem, that on another click the window1 will become active window. But the code will set window2 as active.

    It looks like the iterate an object_cast will do something with the sub windows created.
    Is there an error in my iterate code? Do I have to release the not "needed" sub windows?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      The code looks fine. Casting a base QWidget * to your actual subclass should no do anything to the focus handling.

      It does sound like this
      https://bugreports.qt.io/browse/QTBUG-44630
      But not completely the same.

      Just to understand.
      You open win1 and win2
      then when you click button 2 again, it checks to see if already open
      and if finds it then try to set focus to it.
      However, on the screen, the MdiWin 1 get focus and not Mdiwin2 as
      one should expect since you set focus in code.

      One thing that i did wonder.
      You take the inner widget (window->widget())
      and call
      mdiChild->activateWindow();
      on it. However, its technically not the actual window so i wonder if it makes
      any difference doing
      window->activateWindow(); instead ?

      1 Reply Last reply
      1
      • P Offline
        P Offline
        pixbyte
        wrote on last edited by
        #3

        I think it is a QT bug.

        mrjjM 1 Reply Last reply
        0
        • P pixbyte

          I think it is a QT bug.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @pixbyte
          Hi
          It could be.
          You can report it here
          https://bugreports.qt.io/

          Please make small complete example that reproduces this behavior to be included
          in the bug report. If you don't - its very unlikely its ever looked at.

          Also, did
          window->activateWindow();
          do the same ?

          1 Reply Last reply
          1

          • Login

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