Results 1 to 19 of 19

Thread: QT 4.1.1/X11/QTopia Core : seg fault after sub-classing QMainWindow

  1. #1
    Join Date
    Feb 2006
    Posts
    12

    Default QT 4.1.1/X11/QTopia Core : seg fault after sub-classing QMainWindow

    Hi all,

    I am currently writing a GUI based application using QT4.1.1. This app will run on X11 and Embedded environments ( using Qtopia Core ).

    I am using QT Designer to draw all the app GUI, and I use a QMainWindow as a base for the whole app.

    During my development I noticed I was getting seg faults when I was using a QFileWindow. More precisly, the built-in functions provided by QFileWindow ( create dir, erase dir,... ) accessible by the buttons cause EVERY time seg fault when the buttons are hit.

    so let me show here a custom implementation I wrote to make that bug appening:

    ui_MainWindow.h is autogenerated by QTDesigner then uic:

    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <QtCore/QVariant>
    5. #include <QtGui/QAction>
    6. #include <QtGui/QApplication>
    7. #include <QtGui/QButtonGroup>
    8. #include <QtGui/QMainWindow>
    9. #include <QtGui/QMenuBar>
    10. #include <QtGui/QPushButton>
    11. #include <QtGui/QStatusBar>
    12. #include <QtGui/QWidget>
    13.  
    14. class Ui_MainWindow
    15. {
    16. public:
    17. QWidget *centralwidget;
    18. QPushButton *pushButton;
    19. QMenuBar *menubar;
    20. QStatusBar *statusbar;
    21.  
    22. void setupUi(QMainWindow *MainWindow)
    23. {
    24. MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
    25. MainWindow->resize(QSize(800, 600).expandedTo(MainWindow->minimumSizeHint()));
    26. centralwidget = new QWidget(MainWindow);
    27. centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
    28. pushButton = new QPushButton(centralwidget);
    29. pushButton->setObjectName(QString::fromUtf8("pushButton"));
    30. pushButton->setGeometry(QRect(300, 170, 87, 26));
    31. MainWindow->setCentralWidget(centralwidget);
    32. menubar = new QMenuBar(MainWindow);
    33. menubar->setObjectName(QString::fromUtf8("menubar"));
    34. menubar->setGeometry(QRect(0, 0, 800, 26));
    35. MainWindow->setMenuBar(menubar);
    36. statusbar = new QStatusBar(MainWindow);
    37. statusbar->setObjectName(QString::fromUtf8("statusbar"));
    38. statusbar->setGeometry(QRect(0, 581, 800, 19));
    39. MainWindow->setStatusBar(statusbar);
    40. retranslateUi(MainWindow);
    41.  
    42. QMetaObject::connectSlotsByName(MainWindow);
    43. } // setupUi
    44.  
    45. void retranslateUi(QMainWindow *MainWindow)
    46. {
    47. MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0, QApplication::UnicodeUTF8));
    48. pushButton->setText(QApplication::translate("MainWindow", "PushButton", 0, QApplication::UnicodeUTF8));
    49. Q_UNUSED(MainWindow);
    50. } // retranslateUi
    51.  
    52. };
    53.  
    54. namespace Ui {
    55. class MainWindow: public Ui_MainWindow {};
    56. } // namespace Ui
    57.  
    58. #endif // MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 

    here my implementation files:

    Qt Code:
    1. // main.cpp
    2.  
    3. #include "CLr4kds.h"
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication app(argc, argv);
    8. CLr4kds lr4kds;
    9. return app.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. // CLr4kds.h
    2.  
    3. #ifndef CLR4KDS_H
    4. #define CLR4KDS_H
    5.  
    6. #include <QApplication>
    7. #include <QWidget>
    8. #include <QMessageBox>
    9. #include <QObject>
    10. #include <QDialog>
    11. #include <QtGui>
    12.  
    13. #include "ui_MainWindow.h"
    14.  
    15. class CLr4kds : public QMainWindow, public Ui::MainWindow
    16. {
    17. Q_OBJECT
    18.  
    19. public:
    20. CLr4kds();
    21.  
    22. private:
    23. QMainWindow *window;
    24.  
    25. public slots:
    26.  
    27. virtual void saveAs ();
    28. };
    29.  
    30.  
    31. #endif //CLR4KDS
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. // CLr4kds.cpp
    2.  
    3. #include "CLr4kds.h"
    4.  
    5. CLr4kds::CLr4kds ()
    6. {
    7. window = new QMainWindow;
    8. this->setupUi ( window );
    9.  
    10. // CUSTOM CONNECTIONS
    11. connect ( this->pushButton, SIGNAL ( clicked () ), this, SLOT ( saveAs () ) );
    12.  
    13. window->showMaximized ();
    14.  
    15. }
    16.  
    17. void CLr4kds::saveAs ()
    18. {
    19. QString ret = QFileDialog::getSaveFileName( this );
    20. }
    To copy to clipboard, switch view to plain text mode 

    This very simple example, has been compiled on diffrent machines with different release of QT 4.1. The error is always the same :

    - launch the app
    - click on the unique button, a save dialogbox will pop up
    - create a directory with the builtin function/button
    - try to erase that directory with a right click on it and "Delete"

    the app should quit if you do that.

    So if someone can tell me where is my mistake when I subclass QMainWindow it would be great.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QT 4.1.1/X11/QTopia Core : seg fault after sub-classing QMainWindow

    I don't understand why do you have a QMainWindow inside a QMainWindow...
    This is bad design IMHO.

    Also you use :
    connect ( this->pushButton, SIGNAL ( clicked () ), this, SLOT ( saveAs () ) );
    And I think you mean:
    connect ( window->pushButton, SIGNAL ( clicked () ), this, SLOT ( saveAs () ) );

  3. #3
    Join Date
    Feb 2006
    Posts
    12

    Default Re: QT 4.1.1/X11/QTopia Core : seg fault after sub-classing QMainWindow

    Hi High_flyer,

    thanx for the answer. I modified my short example, and I still have the exact issue:

    Qt Code:
    1. #ifndef UI_MAINWINDOW_H
    2. #define UI_MAINWINDOW_H
    3.  
    4. #include <QtCore/QVariant>
    5. #include <QtGui/QAction>
    6. #include <QtGui/QApplication>
    7. #include <QtGui/QButtonGroup>
    8. #include <QtGui/QMainWindow>
    9. #include <QtGui/QMenuBar>
    10. #include <QtGui/QPushButton>
    11. #include <QtGui/QStatusBar>
    12. #include <QtGui/QWidget>
    13.  
    14. class Ui_MainWindow
    15. {
    16. public:
    17. QWidget *centralwidget;
    18. QPushButton *pushButton;
    19. QMenuBar *menubar;
    20. QStatusBar *statusbar;
    21.  
    22. void setupUi(QMainWindow *MainWindow)
    23. {
    24. MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
    25. MainWindow->resize(QSize(800, 600).expandedTo(MainWindow->minimumSizeHint()));
    26. centralwidget = new QWidget(MainWindow);
    27. centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
    28. pushButton = new QPushButton(centralwidget);
    29. pushButton->setObjectName(QString::fromUtf8("pushButton"));
    30. pushButton->setGeometry(QRect(300, 170, 87, 26));
    31. MainWindow->setCentralWidget(centralwidget);
    32. menubar = new QMenuBar(MainWindow);
    33. menubar->setObjectName(QString::fromUtf8("menubar"));
    34. menubar->setGeometry(QRect(0, 0, 800, 26));
    35. MainWindow->setMenuBar(menubar);
    36. statusbar = new QStatusBar(MainWindow);
    37. statusbar->setObjectName(QString::fromUtf8("statusbar"));
    38. statusbar->setGeometry(QRect(0, 581, 800, 19));
    39. MainWindow->setStatusBar(statusbar);
    40. retranslateUi(MainWindow);
    41.  
    42. QMetaObject::connectSlotsByName(MainWindow);
    43. } // setupUi
    44.  
    45. void retranslateUi(QMainWindow *MainWindow)
    46. {
    47. MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0, QApplication::UnicodeUTF8));
    48. pushButton->setText(QApplication::translate("MainWindow", "PushButton", 0, QApplication::UnicodeUTF8));
    49. Q_UNUSED(MainWindow);
    50. } // retranslateUi
    51.  
    52. };
    53.  
    54. namespace Ui {
    55. class MainWindow: public Ui_MainWindow {};
    56. } // namespace Ui
    57.  
    58. #endif // UI_MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. // CMainWindow.h
    2.  
    3. #ifndef CMAINWINDOW_H
    4. #define CMAINWINDOW_H
    5.  
    6. #include <QApplication>
    7. #include <QWidget>
    8. #include <QMessageBox>
    9. #include <QObject>
    10. #include <QDialog>
    11. #include <QtGui>
    12.  
    13. #include "ui_MainWindow.h"
    14.  
    15.  
    16. class CMainWindow : public QMainWindow
    17. {
    18. Q_OBJECT
    19.  
    20. public:
    21. CMainWindow();
    22. ~CMainWindow();
    23.  
    24. private:
    25. Ui_MainWindow ui;
    26.  
    27. public slots:
    28.  
    29. void saveAs ();
    30. };
    31.  
    32.  
    33. #endif // CMAINWINDOW
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. // CMainWindow.cpp
    2.  
    3. #include "CMainWindow.h"
    4.  
    5. CMainWindow::CMainWindow ()
    6. {
    7. ui.setupUi ( this );
    8.  
    9. // CUSTOM CONNECTIONS
    10. connect ( ui.pushButton, SIGNAL ( clicked () ), this, SLOT ( saveAs () ) );
    11.  
    12.  
    13. }
    14.  
    15. CMainWindow::~CMainWindow ()
    16. {}
    17.  
    18.  
    19.  
    20. void CMainWindow::saveAs ()
    21. {
    22. QString ret = QFileDialog::getSaveFileName( this );
    23. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. // main.cpp
    2.  
    3. #include "CMainWindow.h"
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication app(argc, argv);
    8. CMainWindow lr4kds;
    9. lr4kds.show();
    10. app.exec ();
    11.  
    12. return 0;
    13. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QT 4.1.1/X11/QTopia Core : seg fault after sub-classing QMainWindow

    What does the debugger say? Do dialogs in standard Qt apps (like Designer, examples, etc.) work properly?

    Also be sure to call the base class constructor in the constructor of your subclass.

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QT 4.1.1/X11/QTopia Core : seg fault after sub-classing QMainWindow

    Without analyzing your code any further, I wanna ask you to test if you can reproduce the same error with as simple code as this:

    Qt Code:
    1. #include <QtGui>
    2. int main(int argc, char *argv[])
    3. {
    4. QApplication a(argc, argv);
    5. QFileDialog::getSaveFileName();
    6. a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
    7. return a.exec();
    8. }
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Feb 2006
    Posts
    12

    Default Re: QT 4.1.1/X11/QTopia Core : seg fault after sub-classing QMainWindow

    Hi,

    Excuse my english, maybe I was not clear here.

    What I am trying to do is to design the whole GUI with designer, generate a header file from the .ui file and sub class that header in another class to add custom SLOTS and processes.

    So, I dont want to make any modification to the header generated by UIC.

    My problem is that I dont find anywhere the proper way to sub-class QMainWindow, apparently.

    To answer you questions:

    - yes, it does work properly with Dialog
    - the debugger refers to : QDirModelPrivate::restorePersistentIndexes () this is where it stops

    By the way, if you use the "Trolltech" way for QMainWindow, ie the "application" example in the "examples" dir from the QT source, and open a "save as" dialog, it works !!!!

    But once again, I need the sub classing approach, since I need to keep a way of maintaining my GUI with designer, I dont want to mess with the header file comming from the UIC.

    So if you have an idea, I am really lost with that ....

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QT 4.1.1/X11/QTopia Core : seg fault after sub-classing QMainWindow

    Quote Originally Posted by jlarsj
    - the debugger refers to : QDirModelPrivate::restorePersistentIndexes () this is where it stops
    What about the rest of the call stack?

    And did you correct your code by calling the superclass constructor?

    Qt Code:
    1. CMainWindow::CMainWindow () : QMainWindow(0)
    2. {
    3. ui.setupUi ( this );
    4. connect ( ui.pushButton, SIGNAL ( clicked () ), this, SLOT ( saveAs () ) );
    5. }
    To copy to clipboard, switch view to plain text mode 

  8. #8
    Join Date
    Feb 2006
    Posts
    12

    Default Re: QT 4.1.1/X11/QTopia Core : seg fault after sub-classing QMainWindow

    Hi,

    here is the output of the stack after crashing :

    Qt Code:
    1. ASSERT: "persistent.indexes.count() == savedPaths.count()" in file itemviews/qdirmodel.cpp, line 1332
    2.  
    3. Program received signal SIGABRT, Aborted.
    4. [Switching to Thread 16384 (LWP 25879)]
    5. 0x40bf67c1 in kill () from /lib/libc.so.6
    6. (gdb) bt
    7. #0 0x40bf67c1 in kill () from /lib/libc.so.6
    8. #1 0x40a9f771 in pthread_kill () from /lib/libpthread.so.0
    9. #2 0x40a9fa7b in raise () from /lib/libpthread.so.0
    10. #3 0x40bf6554 in raise () from /lib/libc.so.6
    11. #4 0x40bf7a88 in abort () from /lib/libc.so.6
    12. #5 0x4092cc33 in qt_message_output (msgType=QtFatalMsg,
    13. buf=0xbfff97a0 "ASSERT: \"persistent.indexes.count() == savedPaths.count()\" in file itemviews/qdirmodel.cpp, line 1332") at global/qglobal.cpp:1895
    14. #6 0x4092d0c7 in qFatal (msg=0x40a0f6e0 "ASSERT: \"%s\" in file %s, line %d") at global/qglobal.cpp:2111
    15. #7 0x4092c7ed in qt_assert (assertion=0x406040c0 "persistent.indexes.count() == savedPaths.count()", file=0x40603f97 "itemviews/qdirmodel.cpp",
    16. line=1332) at global/qglobal.cpp:1660
    17. #8 0x40588cf2 in QDirModelPrivate::restorePersistentIndexes (this=0x80b01a0) at itemviews/qdirmodel.cpp:1332
    18. #9 0x40586b18 in QDirModel::refresh (this=0x80ad1b0, parent=@0xbfffb8c0) at itemviews/qdirmodel.cpp:948
    19. #10 0x40587c51 in QDirModel::rmdir (this=0x80ad1b0, index=@0xbfffb910) at itemviews/qdirmodel.cpp:1138
    20. #11 0x40524449 in QFileDialogPrivate::deleteCurrent (this=0x80afe00) at dialogs/qfiledialog.cpp:1428
    21. #12 0x4052a34b in QFileDialog::qt_metacall (this=0x80ad528, _c=InvokeMetaMethod, _id=18, _a=0xbfffbe80) at moc_qfiledialog.cpp:144
    22. #13 0x409ece67 in QMetaObject::activate (sender=0x80bc748, from_signal_index=5, to_signal_index=6, argv=0xbfffbe80) at kernel/qobject.cpp:2670
    23. #14 0x409ed0ba in QMetaObject::activate (sender=0x80bc748, m=0x4062c0c0, from_local_signal_index=1, to_local_signal_index=2, argv=0xbfffbe80)
    24. at kernel/qobject.cpp:2717
    25. #15 0x401b54b5 in QAction::triggered (this=0x80bc748, _t1=false) at moc_qaction.cpp:183
    26. #16 0x401b4c7d in QAction::activate (this=0x80bc748, event=Trigger) at kernel/qaction.cpp:894
    27. #17 0x4048ea2e in QMenuPrivate::activateAction (this=0x80c3770, action=0x80bc748, action_e=Trigger) at widgets/qmenu.cpp:662
    28. #18 0x40492e0c in QMenu::mouseReleaseEvent (this=0xbfffca00, e=0xbfffc4f0) at widgets/qmenu.cpp:1703
    29. #19 0x4020b025 in QWidget::event (this=0xbfffca00, event=0xbfffc4f0) at kernel/qwidget.cpp:4965
    30. #20 0x4049320d in QMenu::event (this=0xbfffca00, e=0xbfffc4f0) at widgets/qmenu.cpp:1770
    31. #21 0x401c0011 in QApplicationPrivate::notify_helper (this=0x804cd78, receiver=0xbfffca00, e=0xbfffc4f0) at kernel/qapplication.cpp:3125
    32. #22 0x401bee52 in QApplication::notify (this=0xbfffebf0, receiver=0xbfffca00, e=0xbfffc4f0) at kernel/qapplication.cpp:2855
    33. #23 0x401c21fc in QCoreApplication::sendSpontaneousEvent (receiver=0xbfffca00, event=0xbfffc4f0) at qcoreapplication.h:174
    34. #24 0x40220a37 in QETWidget::translateMouseEvent (this=0xbfffca00, event=0xbfffc800) at kernel/qapplication_x11.cpp:3517
    35. #25 0x4021e574 in QApplication::x11ProcessEvent (this=0xbfffebf0, event=0xbfffc800) at kernel/qapplication_x11.cpp:2701
    36. #26 0x40237430 in QEventDispatcherX11::processEvents (this=0x80516c0, flags={i = 20}) at kernel/qeventdispatcher_x11.cpp:112
    37. #27 0x409d5a8c in QEventLoop::processEvents (this=0xbfffc980, flags={i = 20}) at kernel/qeventloop.cpp:124
    38. #28 0x409d5b79 in QEventLoop::exec (this=0xbfffc980, flags={i = 0}) at kernel/qeventloop.cpp:164
    39. #29 0x404919d2 in QMenu::exec (this=0xbfffca00, p=@0xbfffc9c8, action=0x0) at widgets/qmenu.cpp:1479
    40. #30 0x40523d1c in QFileDialogPrivate::showContextMenu (this=0x80afe00, pos=@0xbfffd540) at dialogs/qfiledialog.cpp:1365
    41. #31 0x4052a303 in QFileDialog::qt_metacall (this=0x80ad528, _c=InvokeMetaMethod, _id=15, _a=0xbfffcf98) at moc_qfiledialog.cpp:141
    42. #32 0x409ece67 in QMetaObject::activate (sender=0x80bd470, from_signal_index=4, to_signal_index=4, argv=0xbfffcf98) at kernel/qobject.cpp:2670
    43. #33 0x409ed06e in QMetaObject::activate (sender=0x80bd470, m=0x4062d2f4, local_signal_index=0, argv=0xbfffcf98) at kernel/qobject.cpp:2708
    44. #34 0x4020fae4 in QWidget::customContextMenuRequested (this=0x80bd470, _t1=@0xbfffd540) at moc_qwidget.cpp:312
    45. #35 0x4020b8b6 in QWidget::event (this=0x80bd470, event=0xbfffd530) at kernel/qwidget.cpp:5115
    46. #36 0x4045f92e in QFrame::event (this=0x80bd470, e=0xbfffd530) at widgets/qframe.cpp:609
    47. #37 0x404e462b in QAbstractScrollArea::viewportEvent (this=0x80bd470, e=0xbfffd530) at widgets/qabstractscrollarea.cpp:471
    48. #38 0x4054440f in QAbstractItemView::viewportEvent (this=0x80bd470, event=0xbfffd530) at itemviews/qabstractitemview.cpp:949
    49. #39 0x404e4fae in QAbstractScrollAreaPrivate::viewportEvent (this=0x80bd490, e=0xbfffd530) at widgets/qabstractscrollarea.cpp:93
    50. #40 0x404e2fbf in QAbstractScrollAreaViewport::event (this=0x8096d70, e=0xbfffd530) at widgets/qabstractscrollarea.cpp:105
    To copy to clipboard, switch view to plain text mode 

    And, I did modify my code to call the superclass constructor.

  9. #9
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QT 4.1.1/X11/QTopia Core : seg fault after sub-classing QMainWindow

    What is this?:
    QFileDialog::getSaveFileName( this );

    here is the definition of QFileDialog::getSaveFileName():
    QString QFileDialog::getSaveFileName ( const QString & startWith = QString::null, const QString & filter = QString::null, QWidget * parent = 0, const char * name = 0, const QString & caption = QString::null, QString * selectedFilter = 0, bool resolveSymlinks = TRUE )
    As you can see, no room for 'this', unless you do:
    QFileDialog::getSaveFileName( QString::null,QString::null,this );
    Try to call it with out any parameters, and see what happens.

  10. #10
    Join Date
    Feb 2006
    Posts
    12

    Default Re: QT 4.1.1/X11/QTopia Core : seg fault after sub-classing QMainWindow

    Allright,

    In the online doc : http://doc.trolltech.com/4.1/qfiledi...etSaveFileName

    here is the definition :

    QString QFileDialog::getSaveFileName ( QWidget * parent = 0, const QString & caption = QString(), const QString & dir = QString(), const QString & filter = QString(), QString * selectedFilter = 0, Options options = 0 ) [static]

    And, yes I tried without any argument, still EXACTly the same results.

  11. #11
    Join Date
    Feb 2006
    Posts
    12

    Default Re: QT 4.1.1/X11/QTopia Core : seg fault after sub-classing QMainWindow

    Ok, I rewrote my code using the multiple inheritance approach, here is the code :

    Qt Code:
    1. #ifndef UI_MAINWINDOW_H
    2. #define UI_MAINWINDOW_H
    3.  
    4. #include <QtCore/QVariant>
    5. #include <QtGui/QAction>
    6. #include <QtGui/QApplication>
    7. #include <QtGui/QButtonGroup>
    8. #include <QtGui/QMainWindow>
    9. #include <QtGui/QMenuBar>
    10. #include <QtGui/QPushButton>
    11. #include <QtGui/QStatusBar>
    12. #include <QtGui/QWidget>
    13.  
    14. class Ui_MainWindow
    15. {
    16. public:
    17. QWidget *centralwidget;
    18. QPushButton *pushButton;
    19. QMenuBar *menubar;
    20. QStatusBar *statusbar;
    21.  
    22. void setupUi(QMainWindow *MainWindow)
    23. {
    24. MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
    25. MainWindow->resize(QSize(800, 600).expandedTo(MainWindow->minimumSizeHint()));
    26. centralwidget = new QWidget(MainWindow);
    27. centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
    28. pushButton = new QPushButton(centralwidget);
    29. pushButton->setObjectName(QString::fromUtf8("pushButton"));
    30. pushButton->setGeometry(QRect(300, 170, 87, 26));
    31. MainWindow->setCentralWidget(centralwidget);
    32. menubar = new QMenuBar(MainWindow);
    33. menubar->setObjectName(QString::fromUtf8("menubar"));
    34. menubar->setGeometry(QRect(0, 0, 800, 26));
    35. MainWindow->setMenuBar(menubar);
    36. statusbar = new QStatusBar(MainWindow);
    37. statusbar->setObjectName(QString::fromUtf8("statusbar"));
    38. statusbar->setGeometry(QRect(0, 581, 800, 19));
    39. MainWindow->setStatusBar(statusbar);
    40. retranslateUi(MainWindow);
    41.  
    42. QMetaObject::connectSlotsByName(MainWindow);
    43. } // setupUi
    44.  
    45. void retranslateUi(QMainWindow *MainWindow)
    46. {
    47. MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0, QApplication::UnicodeUTF8));
    48. pushButton->setText(QApplication::translate("MainWindow", "PushButton", 0, QApplication::UnicodeUTF8));
    49. Q_UNUSED(MainWindow);
    50. } // retranslateUi
    51.  
    52. };
    53.  
    54. namespace Ui {
    55. class MainWindow: public Ui_MainWindow {};
    56. } // namespace Ui
    57.  
    58. #endif // UI_MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. // CMainWindow.h
    2.  
    3. #ifndef CMAINWINDOW_H
    4. #define CMAINWINDOW_H
    5.  
    6. #include <QApplication>
    7. #include <QWidget>
    8. #include <QMessageBox>
    9. #include <QObject>
    10. #include <QDialog>
    11. #include <QtGui>
    12.  
    13. #include "ui_MainWindow.h"
    14.  
    15.  
    16. class CMainWindow : public QMainWindow, private Ui::MainWindow
    17. {
    18. Q_OBJECT
    19.  
    20. public:
    21. CMainWindow( QWidget *parent = 0 );
    22.  
    23. public slots:
    24.  
    25. void saveAs ();
    26. };
    27.  
    28.  
    29. #endif // CMAINWINDOW
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. // CMainWindow.cpp
    2.  
    3. #include "CMainWindow.h"
    4.  
    5. CMainWindow::CMainWindow ( QWidget *parent ) : QMainWindow ( parent )
    6. {
    7. setupUi ( this );
    8.  
    9. // CUSTOM CONNECTIONS
    10. connect ( pushButton, SIGNAL ( clicked () ), this, SLOT ( saveAs () ) );
    11.  
    12. }
    13.  
    14. void CMainWindow::saveAs ()
    15. {
    16. QString ret = QFileDialog::getSaveFileName ( this );
    17. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. // main.cpp
    2.  
    3. #include "CMainWindow.h"
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication app(argc, argv);
    8. CMainWindow lr4kds;
    9. lr4kds.show();
    10. app.exec ();
    11.  
    12. return 0;
    13. }
    To copy to clipboard, switch view to plain text mode 

    I still have the same results, I really dont get it !!!

  12. #12
    Join Date
    Feb 2006
    Posts
    12

    Default Re: QT 4.1.1/X11/QTopia Core : seg fault after sub-classing QMainWindow

    By the way, I just tried to compile this code and run it under Win32, it is working perfectly.

  13. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT 4.1.1/X11/QTopia Core : seg fault after sub-classing QMainWindow

    I've tried the code from your second post and it works without any problems on my system (Qt 4.1.1, PLD Linux).

  14. #14
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QT 4.1.1/X11/QTopia Core : seg fault after sub-classing QMainWindow

    Quote Originally Posted by jlarsj
    Allright,

    In the online doc : http://doc.trolltech.com/4.1/qfiledi...etSaveFileName

    here is the definition :

    QString QFileDialog::getSaveFileName ( QWidget * parent = 0, const QString & caption = QString(), const QString & dir = QString(), const QString & filter = QString(), QString * selectedFilter = 0, Options options = 0 ) [static]

    And, yes I tried without any argument, still EXACTly the same results.
    You are right ofcourse, I was sure I was looking at the QT4 docs, sorry about that.

  15. #15
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QT 4.1.1/X11/QTopia Core : seg fault after sub-classing QMainWindow

    Did you try to make clean && qmake && make your app again?

  16. #16
    Join Date
    Feb 2006
    Posts
    12

    Default Re: QT 4.1.1/X11/QTopia Core : seg fault after sub-classing QMainWindow

    Yes Wysota I did... I am a little bit lost in that, here what I found:

    I have :

    1) QT 4.1.1 + minGW32 on a XP SP2 machine
    2) QT 4.1.1 + gcc 3.3.5 + Xfree86 on a Debian machine with 2.4.31 Kernel
    3) QT 4.1.1 + gcc 3.4.5 +Xorg on a Kubuntu with 2.6.12-9 Kernel
    4) QTopia core 4.1.1 + gcc 3.3.5 plus FrameBuffer driver on a Debian machine with 2.4.31 kernel

    Using the code just above here are the results :

    1) work perfectly, no bug
    2) seg fault when trying to do a right click/ delete a directory
    3) works perfectly, no bug
    4) seg fault when trying to do a right click/ delete a directory

    So, using 2.4.31 Kernel with gcc 3.3.5 might be the cause, I dont know its far beyond my expertise, but I think there is something incompatible between QT4.1.1/QTopia and the 2.4.31 and GCC 3.3.5.

    So does someone has any idea ?

  17. #17
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QT 4.1.1/X11/QTopia Core : seg fault after sub-classing QMainWindow

    Check Qt dependencies. Maybe it depends on an incorrect version of some library. Did you get any messages from Qt (apart from that assert statement) while the app was running? Did you compile Qt yourself or do you have it from a binary distribution? Was it compiled using the same compiler? Are you using a stable version of Qt (the one which was released today) or a daily snapshot?

  18. #18
    Join Date
    Feb 2006
    Posts
    12

    Default Re: QT 4.1.1/X11/QTopia Core : seg fault after sub-classing QMainWindow

    Did you get any messages from Qt (apart from that assert statement) while the app was running?
    No, I dont get any other messages while the app is running.

    Did you compile Qt yourself or do you have it from a binary distribution?
    Yes, I did compile QT myself.

    Was it compiled using the same compiler?
    Yes

    Are you using a stable version of Qt (the one which was released today) or a daily snapshot?
    I am using a daily snapshot : qt-x11-opensource-src-4.1.1-snapshot-20060221

  19. #19
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QT 4.1.1/X11/QTopia Core : seg fault after sub-classing QMainWindow

    Quote Originally Posted by jlarsj
    I am using a daily snapshot : qt-x11-opensource-src-4.1.1-snapshot-20060221
    Try using the stable version instead and see if the problem persists.

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.