Results 1 to 3 of 3

Thread: Public function called on MDISubWindow ignores code

  1. #1
    Join Date
    Jun 2007
    Location
    Louisiana
    Posts
    77
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Public function called on MDISubWindow ignores code

    I have created several MDISubWindows in an MDIArea.

    I call a public function on one of the MDISubWindow children from the MDI MainWindow. Objects created by code in the MDISubWindow constructor are not treated as members of the window. In fact the objects in the MDISubWindow needed, cause a seg fault when used from the MDI MainWindow. This does not happen when code in the MDISubWindow uses the same objects. What gives?

  2. #2
    Join Date
    Sep 2008
    Location
    Munich
    Posts
    32
    Thanked 8 Times in 6 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Public function called on MDISubWindow ignores code

    Can you provide a small example code (isolating the cause)? It's difficult for me to understand what happens here.

    - Juergen

  3. #3
    Join Date
    Jun 2007
    Location
    Louisiana
    Posts
    77
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Public function called on MDISubWindow ignores code

    Ok, here are some code snippets from the application. . .

    In MDI MainWindow:
    Qt Code:
    1. void MainWindow::createMdiPrevQSOs()
    2. {
    3. // show the window
    4. mdiPrev = new mdiPrevQSOs;
    5. mdiArea->addSubWindow(mdiPrev);
    6. mdiPrev->show();
    7. }
    To copy to clipboard, switch view to plain text mode 
    long after creation:
    Qt Code:
    1. void MainWindow::slotUpdatePrev()
    2. {
    3. QList<QMdiSubWindow *> windows = mdiArea->subWindowList();
    4. foreach (QMdiSubWindow *window, mdiArea->subWindowList())
    5. {
    6. if (window->windowTitle().startsWith(tr("Previous"),Qt::CaseInsensitive))
    7. {
    8. mdiPrevQSOs *child = qobject_cast<mdiPrevQSOs *>(window);
    9. if (child->findPrev()) // (debug shows seg fault previous step is here)
    10. {
    11. . . .
    12. }
    13. }
    14. }
    15. . . .
    16. }
    To copy to clipboard, switch view to plain text mode 
    the MDISubWindow has a list Widget that is filled by the called function.

    mdiPrevQSOs constructor:
    Qt Code:
    1. mdiPrevQSOs::mdiPrevQSOs(QWidget *parent) : QDialog(parent)
    2. {
    3. setAttribute(Qt::WA_DeleteOnClose);
    4. . . .
    5. widget = new QWidget(this);
    6. widget->setObjectName(QString::fromUtf8("widget"));
    7. . . .
    8. listView = new QTreeView(widget);
    9. listView->setObjectName(QString::fromUtf8("listView"));
    10. }
    To copy to clipboard, switch view to plain text mode 
    the public function called:
    Qt Code:
    1. bool mdiPrevQSOs::findPrev()
    2. {
    3. . . .
    4. // create a query . . .
    5. // create a QStandardItemModel for the tree view. . .
    6. // fill the model with data from the query . . .
    7. . . .
    8. // (this line crashes with a seg fault)
    9. listView->setModel(s_model); // the tree view created in the constructor
    10. . . .
    11. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 12:57
  2. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 17:33
  3. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  4. Link Errors
    By magikalpnoi in forum Qt Programming
    Replies: 5
    Last Post: 25th September 2006, 22:04
  5. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.