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. Mdichild related problem

Mdichild related problem

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.2k 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.
  • D Offline
    D Offline
    DomDom
    wrote on last edited by
    #1

    Hi,

    I got a mdichild class (derived from QPlainTextEdit).
    When I try to "play" with it (using setTabStopWidth ortrying to move its cursor for example).
    It crashed in QScopedPointer.h in the function

    @ inline T *data() const
    {
    return d; <============ crash here with an invalid "this" value .
    }@
    the crash only appends if my mdichild already exists (i.e. if found in mdiArea->subWindowList() );
    When the mdichild does not exist yet and just created and add with mdiArea->addSubWindow(child); evrything is

    Is it a thread related problem ?
    Do i need to do something special (like waiting for the mdichild to show up) before trying to work with it ?

    Any help will be appreciated.
    Thanks in advance

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      Please give us a bit more information.

      • Are you working with worker threads?
      • What do they do?

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DomDom
        wrote on last edited by
        #3

        No, I don't use worker threads at all.
        I started with this sample :
        "http://qt-project.org/doc/qt-4.8/mainwindows-mdi.html":http://qt-project.org/doc/qt-4.8/mainwindows-mdi.html

        And I'm trying to set the tab width here :

        @ void MainWindow::open()
        {
        QString fileName = QFileDialog::getOpenFileName(this);
        if (!fileName.isEmpty()) {
        QMdiSubWindow *existing = findMdiChild(fileName);
        if (existing) {
        mdiArea->setActiveSubWindow(existing);
        existing->MyFunctionToSetTabWidth(); <---Here
        return;
        }

             MdiChild *child = createMdiChild();
             if (child->loadFile&#40;fileName&#41;) {
                 statusBar()->showMessage(tr("File loaded"), 2000);
                 child->show();
             } else {
                 child->close();
             }
         }
        

        }
        @

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #4

          Hm,
          in general, this function looks good. Maybe it's in the sourroundings somewhere. Did you debug the whole thing and check, whether existing points to a valid object?

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply
          0
          • D Offline
            D Offline
            DomDom
            wrote on last edited by
            #5

            Thanks a lot, you were right, it was in the surroundings.
            It was a bad cast. findMdiChild returns a QMdiSubWindow and not directly a widget. The solution was to cast the widget and not directly the subwindow like this :

            @ QMdiSubWindow *subw = findMdiChild(fileName);
            if (subw != NULL)
            {
            existing = qobject_cast<MdiChild *> (subw->widget());
            }@

            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