First time making a program with a GUI, using c++. I have a QTextBrowser that I want to use to provide the user with a text file of lines that they can select, then insert a new line either before or after the selected line. I'm setting up the line-by-line selection using these:

Qt Code:
  1. connect(ListWindow, &QTextBrowser::cursorPositionChanged, this, &MainWindow::handleSelect);
To copy to clipboard, switch view to plain text mode 

and

Qt Code:
  1. void MainWindow::handleSelect(){
  2. ListWindow->moveCursor(QTextCursor::StartOfLine); //move cursor and anchor to start of line
  3. ListWindow->moveCursor(QTextCursor::EndOfLine, QTextCursor::KeepAnchor); //move cursor to end of line without anchor, selecting text between
  4. }
To copy to clipboard, switch view to plain text mode 

When I click a line in the browser, I get this:
"The inferior stopped because it received a signal from the operating system.
Signal name: SIGSEGV
Signal meaning: Segmentation fault"

Each line in handleSelect works on its own, the program only crashes when I run both. What do I need to do to avoid this?