Results 1 to 17 of 17

Thread: Wrong C++ syntax

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2020
    Posts
    28
    Qt products
    Qt5

    Default Re: Wrong C++ syntax

    Partial success.
    Using both old and new "connect" style throws "segmentation fault" at either one.

    It is my understanding that "connect" code placement is not critical - however my crash occurs exactly on "connect" which I have placed in a secondary dialog constructor. My main window dialog is primary.

    RTFM implies that passing null pointer may be the problem...

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,332
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    317
    Thanked 871 Times in 858 Posts

    Default Re: Wrong C++ syntax

    It is my understanding that "connect" code placement is not critical
    No, not true. You must connect the signal and slot before any of the signals you want to process can be issued. The customary place to make the connection is in the constructor of the parent of the two widgets you want to connect. This ensures that the connection is made only once and before either of the connected widgets can do anything. There are other places, but this is the most common.

    RTFM implies that passing null pointer may be the problem...
    Almost always either a null pointer or a pointer that has not been initialized. If you are passing a pointer in to your secondary dialog via a function call, then calling connect() using the variable that holds that pointer before you have made that call (i.e. in the dialog constructor) means you are using an uninitialized pointer.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Using the Qt5 connecy syntax
    By bnosam in forum Newbie
    Replies: 3
    Last Post: 9th February 2015, 02:57
  2. Regarding syntax
    By Yayati.Ekbote in forum Qt Programming
    Replies: 3
    Last Post: 27th January 2010, 14:15
  3. Odd Syntax
    By acxdotfm in forum Qt Programming
    Replies: 2
    Last Post: 24th October 2008, 20:23
  4. wrong syntax or QTcpSocket problem?
    By vito49 in forum Newbie
    Replies: 3
    Last Post: 8th October 2008, 08:12
  5. Syntax Highlighter sample is wrong
    By kib2 in forum Qt Programming
    Replies: 2
    Last Post: 8th November 2007, 21:24

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
  •  
Qt is a trademark of The Qt Company.