Results 1 to 3 of 3

Thread: Segmentation error, dock icons doesnt appears, slots not recognized

  1. #1
    Join Date
    Oct 2011
    Posts
    13
    Thanks
    3
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Segmentation error, dock icons doesnt appears, slots not recognized

    Hi all,
    I'm writing an application and when th compilation is doing well; But when I launch it I have the following messages from debugger :

    Qt Code:
    1. Début du débogageObject::connect: No such slot FenetrePrincipale::genPdf(m_userView,filename) in ..\callTracker\PageUser.cpp:52
    2. Object::connect: No such slot FenetrePrincipale::goTab(m_search,titre) in ..\callTracker\FenetrePrincipale.cpp:49
    3. Object::connect: No such slot FenetrePrincipale::goTab(m_user,titre) in ..\callTracker\FenetrePrincipale.cpp:55
    4. Object::connect: No such slot FenetrePrincipale::goTab(m_user,titre) in ..\callTracker\FenetrePrincipale.cpp:61
    5. Object::connect: No such slot FenetrePrincipale::genPdf(m_search,filename) in ..\callTracker\FenetrePrincipale.cpp:67
    6. Object::connect: No such slot FenetrePrincipale::goTab(m_stat,titre) in ..\callTracker\FenetrePrincipale.cpp:73
    7. Object::connect: No such slot FenetrePrincipale::goTab(m_accueil,titre) in ..\callTracker\FenetrePrincipale.cpp:79
    To copy to clipboard, switch view to plain text mode 

    In addition, th icons of my dock doesn't appears.
    And finally, I got a segmentation error message when I click on search and Make report buttons on the PageAccueil. Can you help me?

    FenetrePrincipale.h
    Qt Code:
    1. #ifndef FENETREPRINCIPALE_H
    2. #define FENETREPRINCIPALE_H
    3.  
    4. #include <QtGui>
    5. #include <QMainWindow>
    6. #include <QtSql>
    7. #include "sstream"
    8. #include "PageAccueil.h"
    9. #include "PageRecherche.h"
    10. #include "PageStat.h"
    11. #include "PageUser.h"
    12.  
    13. class FenetrePrincipale : public QMainWindow
    14. {
    15. Q_OBJECT
    16.  
    17. public:
    18. explicit FenetrePrincipale(QWidget *parent = 0);
    19.  
    20. private:
    21. void creerAction();
    22. void creerDock();
    23.  
    24. public slots:
    25. void creerPageRapport();
    26. void genPdf(QWidget *view, QString filename);
    27.  
    28. void goTab(QWidget *page, QString title);
    29. void goTabint(int position);
    30.  
    31. private:
    32. QTabWidget *m_onglets;
    33.  
    34. PageAccueil *m_accueil;
    35. PageRecherche *m_search;
    36. PageStat *m_stat;
    37. PageUser *m_user;
    38.  
    39. QAction *actionAddUser;
    40. QAction *actionConfig;
    41. QAction *actionSearchCall;
    42. QAction *actionDelUser;
    43. QAction *actionModUser;
    44. QAction *actionReport;
    45. QAction *actionStat;
    46. QAction *actionretourAccueil;
    47. QAction *actionQuit;
    48.  
    49. };
    50.  
    51. #endif // FENETREPRINCIPALE_H
    To copy to clipboard, switch view to plain text mode 

    FenetrePrincipale.cpp
    Qt Code:
    1. #include "FenetrePrincipale.h"
    2.  
    3. FenetrePrincipale::FenetrePrincipale(QWidget *parent) :
    4. QMainWindow(parent)
    5. {
    6. m_accueil=new PageAccueil(this);
    7. m_stat=new PageStat(this);
    8. m_user=new PageUser(this);
    9.  
    10. creerAction();
    11. creerDock();
    12.  
    13. m_onglets=new QTabWidget;
    14. m_onglets->setTabPosition(QTabWidget::East);
    15. m_onglets->addTab(m_accueil,tr("Home"));
    16. m_onglets->addTab(m_user,tr("User"));
    17. m_onglets->addTab(m_stat,tr("Statistics"));
    18.  
    19. connect(m_onglets,SIGNAL(currentChanged(int)),this,SLOT(goTabint(int)));
    20. setCentralWidget(m_onglets);
    21.  
    22. m_onglets->setTabsClosable(true);
    23.  
    24. setMinimumSize(500,350);
    25. setWindowIcon(QIcon("images/logo.png"));
    26. setWindowTitle(tr("callTracker"));
    27. }
    28.  
    29.  
    30. void FenetrePrincipale::creerAction()
    31. {
    32. actionAddUser=new QAction(QIcon("images/add.png"),tr("Add a &user"),this);
    33. actionAddUser->setShortcut(tr("Ctrl+U"));
    34. connect(actionAddUser,SIGNAL(triggered()),m_user,SLOT(addBoite()));
    35.  
    36. actionSearchCall=new QAction(QIcon("images/search.png"),tr("&Search a call"),this);
    37. actionSearchCall->setShortcut(tr("Ctrl+S"));
    38. QString titre("Search & Report");
    39. connect(actionSearchCall,SIGNAL(triggered()),this,SLOT(goTab(m_search,titre)));
    40.  
    41. actionDelUser=new QAction(QIcon("images/del.png"), tr("&Delete user informations"),this);
    42. actionDelUser->setShortcut(tr("Ctrl+D"));
    43. titre=tr("&User");
    44. connect(actionDelUser,SIGNAL(triggered()),this,SLOT(goTab(m_user,titre)));
    45.  
    46. actionModUser=new QAction(tr("&Update user informations"),this);
    47. actionModUser->setShortcut(tr("Ctrl+M"));
    48. titre=tr("User");
    49. connect(actionModUser,SIGNAL(triggered()),this,SLOT(goTab(m_user,titre)));
    50.  
    51. actionReport=new QAction(QIcon("images/rapport"),tr("&Generate a call report"),this);
    52. actionReport->setShortcut(tr("Ctrl+G"));
    53. QString filename=tr("Report");
    54. connect(actionReport,SIGNAL(triggered()),this,SLOT(genPdf(m_search,filename)));
    55.  
    56. actionStat=new QAction(tr("&View calls statistics"),this);
    57. actionStat->setShortcut(tr("Ctrl+V"));
    58. titre=tr("&Statistics");
    59. connect(actionStat,SIGNAL(triggered()),this,SLOT(goTab(m_stat,titre)));
    60.  
    61. actionretourAccueil=new QAction(QIcon("images/accueil.png"),tr("&Home"),this);
    62. actionretourAccueil->setShortcut(tr("Ctrl+A"));
    63. titre=tr("Home");
    64. connect(actionretourAccueil,SIGNAL(triggered()),this,SLOT(goTab(m_accueil,titre)));
    65.  
    66. actionQuit=new QAction(QIcon("images/quit.png"),tr("&Quit"),this);
    67. actionQuit->setShortcut(tr("Ctrl+V"));
    68. connect(actionQuit,SIGNAL(triggered()),qApp,SLOT(quit()));
    69.  
    70. }
    71.  
    72.  
    73. void FenetrePrincipale::creerDock()
    74. {
    75. QDockWidget *dock=new QDockWidget(tr("Actions"),this);
    76. addDockWidget(Qt::LeftDockWidgetArea,dock);
    77. dock->setFeatures(QDockWidget::NoDockWidgetFeatures);
    78. dock->setFixedWidth(100);
    79.  
    80. QWidget *contenuDock=new QWidget;
    81. dock->setWidget(contenuDock);
    82.  
    83. QToolButton *search = new QToolButton;
    84. QToolButton *report = new QToolButton;
    85. QToolButton *retAcc = new QToolButton;
    86.  
    87. add->setIcon(QIcon("images/add.png"));
    88. search->setIcon(QIcon("images/search.png"));
    89. del->setIcon(QIcon("images/del.png"));
    90. mod->setIcon(QIcon("images/mod.png"));
    91. report->setIcon(QIcon("images/report.png"));
    92. retAcc->setIcon(QIcon("images/home.png"));
    93. stati->setIcon(QIcon("images/stat.png"));
    94. quit->setIcon(QIcon("images/quit.png"));
    95.  
    96. add->addAction(actionAddUser);
    97. search->addAction(actionSearchCall);
    98. del->addAction(actionDelUser);
    99. mod->addAction(actionModUser);
    100. report->addAction(actionReport);
    101. retAcc->addAction(actionretourAccueil);
    102. stati->addAction(actionStat);
    103. quit->addAction(actionQuit);
    104.  
    105.  
    106. QVBoxLayout *dockLayout=new QVBoxLayout;
    107. dockLayout->addWidget(add);
    108. dockLayout->addWidget(search);
    109. dockLayout->addWidget(del);
    110. dockLayout->addWidget(mod);
    111. dockLayout->addWidget(report);
    112. dockLayout->addWidget(retAcc);
    113. dockLayout->addWidget(stati);
    114. dockLayout->addWidget(quit);
    115.  
    116. contenuDock->setLayout(dockLayout);
    117.  
    118. }
    119.  
    120. void FenetrePrincipale::goTab(QWidget *page,QString title)
    121. {
    122. int position=m_onglets->indexOf(page);
    123. if(position==-1)
    124. {
    125. m_onglets->addTab(page,title);
    126. }
    127. else
    128. {
    129. m_onglets->setCurrentWidget(page);
    130. };
    131. }
    132.  
    133. void FenetrePrincipale::goTabint(int position)
    134. {
    135. if(position!=-1)
    136. {
    137. m_onglets->setCurrentIndex(position);
    138. };
    139. }
    140.  
    141. void FenetrePrincipale::creerPageRapport()
    142. {
    143. goTab(m_search,tr("Search & Report"));
    144. }
    145.  
    146. void FenetrePrincipale::genPdf(QWidget *view, QString filename)
    147. {
    148. QPrinter printer(QPrinter::HighResolution);
    149. printer.setOutputFileName(filename);
    150. printer.setPaperSize(QPrinter::A4);
    151. printer.setOutputFormat(QPrinter::PdfFormat);
    152. }
    To copy to clipboard, switch view to plain text mode 

    PageAccueil.cpp
    Qt Code:
    1. #include "PageAccueil.h"
    2.  
    3. void PageAccueil::initializeModel(QSqlRelationalTableModel *model)
    4. {
    5. model->setTable("callId");
    6.  
    7. model->setEditStrategy(QSqlTableModel::OnManualSubmit);
    8. model->setRelation(8, QSqlRelation("destination", "number", "type"));
    9. model->setRelation(9, QSqlRelation("user", "cos", "name"));
    10. model->setRelation(10, QSqlRelation("user", "cos","firstname"));
    11.  
    12. model->setHeaderData(0, Qt::Horizontal, tr("Nbr"));
    13. model->setHeaderData(7, Qt::Horizontal, tr("Caller extension"));
    14. model->setHeaderData(1, Qt::Horizontal, tr("Date"));
    15. model->setHeaderData(2, Qt::Horizontal, tr("Hour"));
    16. model->setHeaderData(3, Qt::Horizontal, tr("Duration"));
    17. model->setHeaderData(4, Qt::Horizontal, tr("transfert"));
    18. model->setHeaderData(5, Qt::Horizontal, tr("transfered call?"));
    19. model->setHeaderData(6, Qt::Horizontal, tr("cos used?"));
    20. model->setHeaderData(12, Qt::Horizontal, tr("Destination type"));
    21. model->setHeaderData(11, Qt::Horizontal, tr("Last Name"));
    22. model->setHeaderData(10, Qt::Horizontal, tr("First Name"));
    23.  
    24. model->select();
    25. }
    26.  
    27. QTableView *PageAccueil::createView(const QString &title, QSqlTableModel *model)
    28. {
    29. QTableView *view = new QTableView;
    30. view->setModel(model);
    31. view->setItemDelegate(new QSqlRelationalDelegate(view));
    32. view->setWindowTitle(title);
    33. return view;
    34. }
    35.  
    36. PageAccueil::PageAccueil(QWidget *parent) :
    37. QWidget(parent)
    38. {
    39. initializeModel(&model);
    40.  
    41. QTableView *view = createView(QObject::tr("Lasts calls"), &model);
    42.  
    43. view->setEditTriggers(QAbstractItemView::NoEditTriggers);
    44.  
    45. QPushButton *searchBut=new QPushButton(tr("Search"));
    46. QPushButton *reportBut=new QPushButton(tr("Make a report"));
    47.  
    48. QVBoxLayout *layoutPage=new QVBoxLayout(this);
    49. layoutPage->addWidget(view);
    50. layoutPage->addWidget(searchBut);
    51. layoutPage->addWidget(reportBut);
    52.  
    53. setLayout(layoutPage);
    54.  
    55. connect(searchBut,SIGNAL(clicked()),parent,SLOT(creerPageRapport()));
    56. connect(reportBut,SIGNAL(clicked()),parent,SLOT(creerPageRapport()));
    57. }
    To copy to clipboard, switch view to plain text mode 

    Many thanks.

    I forgot the PageAccueil.h
    Qt Code:
    1. #ifndef PAGEACCUEIL_H
    2. #define PAGEACCUEIL_H
    3.  
    4. #include <QtGui>
    5. #include <QtSql>
    6.  
    7.  
    8. class PageAccueil : public QWidget
    9. {
    10. Q_OBJECT
    11. public:
    12. explicit PageAccueil(QWidget *parent = 0);
    13.  
    14. private:
    15. void initializeModel(QSqlRelationalTableModel *model);
    16. QTableView *createView(const QString &title, QSqlTableModel *model);
    17.  
    18. };
    19.  
    20. #endif // PAGEACCUEIL_H
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Segmentation error, dock icons doesnt appears, slots not recognized

    Quote Originally Posted by phapha View Post
    Qt Code:
    1. Début du débogageObject::connect: No such slot FenetrePrincipale::genPdf(m_userView,filename) in ..\callTracker\PageUser.cpp:52
    2. Object::connect: No such slot FenetrePrincipale::goTab(m_search,titre) in ..\callTracker\FenetrePrincipale.cpp:49
    3. ...
    To copy to clipboard, switch view to plain text mode 
    You have to connect signals and slots using their signature, not variables.
    Qt Code:
    1. connect(mySender, SIGNAL(mySignal(int,int)), myReceiver, SLOT(mySlot(int,int)));
    To copy to clipboard, switch view to plain text mode 
    You do this correctly more than a few times.
    This won't work:
    Qt Code:
    1. connect(actionModUser,SIGNAL(triggered()),this,SLOT(goTab(m_user,titre)));
    To copy to clipboard, switch view to plain text mode 

    What you might need to do here, is create a slot that takes no arguments:
    Qt Code:
    1. connect(actionModUser, SIGNAL(triggered()), this, SLOT(onActionModUserTriggered()));
    2.  
    3. // ...
    4. void FenetrePrincipale::onActionModUserTriggered()
    5. {
    6. // ...
    7. goTab(m_user, titre);
    8. }
    To copy to clipboard, switch view to plain text mode 

    I couldn't look into the dock widget.

    Then the segfault:

    Qt Code:
    1. PageAccueil::PageAccueil(QWidget *parent) :
    2. QWidget(parent)
    3. {
    To copy to clipboard, switch view to plain text mode 

    model is local to this function. You pass it to other objects that keep a pointer to it, but it will be destroyed at the end of this function (the ampersand is a red flag in these cases). Fix it by creating it on the heap:

    Qt Code:
    1. PageAccueil::PageAccueil(QWidget *parent) :
    2. QWidget(parent)
    3. {
    4. initializeModel(model);
    5.  
    6. QTableView *view = createView(QObject::tr("Lasts calls"), model);
    7. // ...
    8. }
    To copy to clipboard, switch view to plain text mode 
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  3. The following user says thank you to franz for this useful post:

    phapha (30th October 2011)

  4. #3
    Join Date
    Oct 2011
    Posts
    13
    Thanks
    3
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Segmentation error, dock icons doesnt appears, slots not recognized

    Thank you Franz; It works. But I have another problem; I m trying to create 3tables in my SQlite database. I use the following code.
    Qt Code:
    1. QSqlQuery query;
    2. query.exec("create table user (UPI int primary key, firstname varchar, lastname varchar, cos int )");
    3. query.exec("insert into person values(380142, 'Danny', 'Young',10)");
    4. query.exec("insert into person values(102222, 'Christine', 'Holand',23)");
    5.  
    6. //The following requests create the tables, but don't insert the data
    7. query.exec("create table destination (number int primary key,type varchar)");
    8. query.exec("insert into destination values(0022921301074, 'local')");
    9. query.exec("insert into destination values(002217780216, 'international')");
    10.  
    11. //The requests below gives an error message
    12. query.exec("create table callId (id int primary key, ext int)")/*, day varchar, moment varchar,duree int,transfer int, transferExist bool,cosExist bool, number int, cos int)")*/;
    13. query.exec("insert into callId values(' ', '2011-10-28','17:25',128,3300,'true','false',0022921301074,' ')");
    14. query.exec("insert into callId values(' ', '2011-10-29','00:29',128,' ','false','true',002217780216,10)");
    To copy to clipboard, switch view to plain text mode 

    The error message is "This application has request the Runtime to terminate at an unusual way".

    And the debugger show the following message :
    Début du débogageASSERT: "idx >= 0 && idx < s" in file ..\..\include/QtCore/../../../../../../ndk_buildrepos/qt-desktop/src/corelib/tools/qvarlengtharray.h, line 107
    Invalid parameter passed to C runtime function.
    Invalid parameter passed to C runtime function.
    Fin du débogage

    Kindly help me;
    Thanks
    Last edited by phapha; 30th October 2011 at 14:38.

Similar Threads

  1. Segmentation error! Please help!!!
    By phapha in forum Newbie
    Replies: 4
    Last Post: 26th October 2011, 18:01
  2. Segmentation error in run
    By kurrachow in forum Newbie
    Replies: 1
    Last Post: 21st April 2011, 14:13
  3. error message appears when function is called
    By babygal in forum Qt Programming
    Replies: 11
    Last Post: 15th June 2010, 00:49
  4. slots and signals don't seem to be recognized
    By Jessehk in forum Qt Programming
    Replies: 2
    Last Post: 31st July 2007, 20:50
  5. Icons missing => segmentation fault
    By antonio.r.tome in forum Qt Programming
    Replies: 4
    Last Post: 8th March 2006, 17:30

Tags for this Thread

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.