Results 1 to 15 of 15

Thread: Segment fault

  1. #1
    Join Date
    Oct 2012
    Posts
    35
    Thanks
    26
    Qt products
    Qt4
    Platforms
    Windows

    Default Segment fault

    Hi All,


    use Qt Creator 4.7 , didn't use designer, a dockwidget has several filters, Segment fault when complied,codes as below:

    dockWidget = new QDockWidget(this);
    dockWidget->setObjectName(QString::fromUtf8("dockWidget"));

    dockWidgetContents = new QWidget();
    dockWidgetContents->setObjectName(QString::fromUtf8("dockWidgetConten ts"));

    gridLayout = new QGridLayout(dockWidgetContents);
    gridLayout->setSpacing(6);
    gridLayout->setObjectName(QString::fromUtf8("gridLayout"));

    horizontalLayout_2 = new QHBoxLayout();//Segment fault
    horizontalLayout_2->setSpacing(6);
    horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout _2"));

    time_dateEdit = new QDateEdit(dockWidgetContents);
    time_dateEdit->setObjectName(QString::fromUtf8("time_dateEdit")) ;

    horizontalLayout_2->addWidget(time_dateEdit);

    horizontalSpacer_2 = new QSpacerItem(18, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);

    horizontalLayout_2->addItem(horizontalSpacer_2);

    lcdNumber = new QLCDNumber(dockWidgetContents);
    lcdNumber->setObjectName(QString::fromUtf8("lcdNumber"));
    horizontalLayout_2->addWidget(lcdNumber);


    gridLayout->addLayout(horizontalLayout_2, 0, 0, 1, 1);

    horizontalLayout = new QHBoxLayout();//segment fault
    horizontalLayout->setSpacing(6);
    horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout "));
    horizontalSlider = new QSlider(dockWidgetContents);
    horizontalSlider->setObjectName(QString::fromUtf8("horizontalSlider "));
    horizontalSlider->setOrientation(Qt::Horizontal);

    horizontalLayout->addWidget(horizontalSlider);

    openBtn = new QPushButton(dockWidgetContents);
    openBtn->setObjectName(QString::fromUtf8("openfileBtn")) ;

    horizontalLayout->addWidget(openfileBtn);

    preBtn = new QPushButton(dockWidgetContents);
    preBtn->setObjectName(QString::fromUtf8("preBtn"));

    horizontalLayout->addWidget(preBtn);

    gridLayout->addLayout(horizontalLayout, 1, 0, 1, 1);

    dockWidget->setWidget(dockWidgetContents);


    Please give me any advice!

    TKS.

    ken

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Segment fault

    explain exactly what you have done for all qt installations - what compiler you used.

    what compiler are you using now?

    What do you do to compile your programs? What is your PATH like?
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

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

    kenchan (6th December 2012)

  4. #3
    Join Date
    Oct 2012
    Posts
    35
    Thanks
    26
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Segment fault

    if the code changed as below, the layout is didn't i want to layout.
    horizontalLayout = new QHBoxLayout(dockWidgetContents);
    horizontalLayout = new QHBoxLayout(dockWidgetContents);

    and if the code changed as below, segment fault also.
    horizontalLayout = new QHBoxLayout(dockWidget );
    horizontalLayout = new QHBoxLayout(dockWidget );

    Hi amleto,
    i use mingw32 to compile my program.

  5. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Segment fault

    hi, please read my post, above, and answer the questions. Thanks.

    also state how you build your application e.g. pro file.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  6. The following user says thank you to amleto for this useful post:

    kenchan (6th December 2012)

  7. #5
    Join Date
    Oct 2012
    Posts
    35
    Thanks
    26
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Segment fault

    Hi amleto,
    i use mingw32 complier.
    complied success if i use designer to build the project which has several filters in dockwidget,
    but i want to write codes to build the project to complete what i want, so i consulted ui_mainwindow.h as above.

    thanks.

    ken

  8. #6
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Segment fault

    It seems you have some difficulty in understanding my questions? You have not answered all of them.

    Qt designer is not even an IDE - it can't even start a compiler so you are not using designer to build your code.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  9. The following user says thank you to amleto for this useful post:

    kenchan (6th December 2012)

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

    Default Re: Segment fault

    Quote Originally Posted by kenchan View Post
    Hi All,


    use Qt Creator 4.7 , didn't use designer, a dockwidget has several filters, Segment fault when complied,codes as below:

    dockWidget = new QDockWidget(this);
    dockWidget->setObjectName(QString::fromUtf8("dockWidget"));

    dockWidgetContents = new QWidget();
    dockWidgetContents->setObjectName(QString::fromUtf8("dockWidgetConten ts"));

    gridLayout = new QGridLayout(dockWidgetContents);
    gridLayout->setSpacing(6);
    gridLayout->setObjectName(QString::fromUtf8("gridLayout"));

    horizontalLayout_2 = new QHBoxLayout();//Segment fault
    horizontalLayout_2->setSpacing(6);
    horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout _2"));

    time_dateEdit = new QDateEdit(dockWidgetContents);
    time_dateEdit->setObjectName(QString::fromUtf8("time_dateEdit")) ;

    horizontalLayout_2->addWidget(time_dateEdit);

    horizontalSpacer_2 = new QSpacerItem(18, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);

    horizontalLayout_2->addItem(horizontalSpacer_2);

    lcdNumber = new QLCDNumber(dockWidgetContents);
    lcdNumber->setObjectName(QString::fromUtf8("lcdNumber"));
    horizontalLayout_2->addWidget(lcdNumber);


    gridLayout->addLayout(horizontalLayout_2, 0, 0, 1, 1);

    horizontalLayout = new QHBoxLayout();//segment fault
    horizontalLayout->setSpacing(6);
    horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout "));
    horizontalSlider = new QSlider(dockWidgetContents);
    horizontalSlider->setObjectName(QString::fromUtf8("horizontalSlider "));
    horizontalSlider->setOrientation(Qt::Horizontal);

    horizontalLayout->addWidget(horizontalSlider);

    openBtn = new QPushButton(dockWidgetContents);
    openBtn->setObjectName(QString::fromUtf8("openfileBtn")) ;

    horizontalLayout->addWidget(openfileBtn);

    preBtn = new QPushButton(dockWidgetContents);
    preBtn->setObjectName(QString::fromUtf8("preBtn"));

    horizontalLayout->addWidget(preBtn);

    gridLayout->addLayout(horizontalLayout, 1, 0, 1, 1);

    dockWidget->setWidget(dockWidgetContents);


    Please give me any advice!

    TKS.

    ken
    So... you got two segmentation faults at once?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. The following user says thank you to wysota for this useful post:

    kenchan (6th December 2012)

  12. #8
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Segment fault

    I didn't even want to go there!
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  13. The following user says thank you to amleto for this useful post:

    kenchan (6th December 2012)

  14. #9
    Join Date
    Oct 2012
    Posts
    35
    Thanks
    26
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Segment fault

    Hi wysota,
    segment fault when app quit, when i debugged, complier prompted segment fault at "QHBoxLayout".

    Hi amleto,

    my English is not good, i'm sorry i don't catch all your meaning.

    TKS.

    ken

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

    Default Re: Segment fault

    If you are getting segmentation faults upon quitting the app, the crash is caused by destructors, not by a constructor. Post the backtrace from your debugger.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  16. The following user says thank you to wysota for this useful post:

    kenchan (6th December 2012)

  17. #11
    Join Date
    Oct 2012
    Posts
    35
    Thanks
    26
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Segment fault

    Hi wysota,

    Good morning!

    thank you for your response.

    when i debugged. information reference to segmentation faults as below:

    MessageBox:
    The inferior stopped because it received a signal from the Operating System.
    Signal name:SIGSEGV
    Signal meaning:Segmentation fault

    debugger:
    Stopped:Segmentation fault by signal SIGSEGV

    Level Function file line address
    0 ~QBoxLayoutItem qboxlayout.cpp 72 0x0112ab69



    if i add QWidget to QHBoxLayout(). complied success. see as below:
    horizontalLayout_2 = new QHBoxLayout(dockWidgetContents );
    horizontalLayout = new QHBoxLayout(dockWidgetContents );

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

    Default Re: Segment fault

    Please post the full backtrace, not only the top frame.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  19. The following user says thank you to wysota for this useful post:

    kenchan (6th December 2012)

  20. #13
    Join Date
    Oct 2012
    Posts
    35
    Thanks
    26
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Segment fault

    Hi All,

    i have handled it. thank you very much.

    ken

  21. #14
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Segment fault

    What was the solution? If someone googles their own problem and finds this thread, they will be frustrated to see 'solved!', but nobody posted the solution...
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  22. The following user says thank you to amleto for this useful post:

    kenchan (25th December 2012)

  23. #15
    Join Date
    Oct 2012
    Posts
    35
    Thanks
    26
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Segment fault

    i used QGridLayout instead of QHBoxLayout, so that the problem have solved!

Similar Threads

  1. I need a 16 segment LCD display control????
    By phoenixcomm in forum Newbie
    Replies: 2
    Last Post: 2nd July 2012, 00:26
  2. segment fault with any QT GUI program
    By earth in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 22nd March 2011, 23:29
  3. Draw directly from a memory segment
    By 25an in forum Qt Programming
    Replies: 1
    Last Post: 28th November 2009, 13:04
  4. Segment fault using a Qt plugin with QTabWidget
    By tarod in forum Qt Programming
    Replies: 2
    Last Post: 14th July 2009, 10:27
  5. Segment fault when using Q3ListBox and QFile
    By hiuao in forum Qt Programming
    Replies: 8
    Last Post: 12th May 2007, 11:51

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.