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:
connect(ListWindow, &QTextBrowser::cursorPositionChanged, this, &MainWindow::handleSelect);
connect(ListWindow, &QTextBrowser::cursorPositionChanged, this, &MainWindow::handleSelect);
To copy to clipboard, switch view to plain text mode
and
void MainWindow::handleSelect(){
ListWindow
->moveCursor
(QTextCursor::StartOfLine);
//move cursor and anchor to start of line ListWindow
->moveCursor
(QTextCursor::EndOfLine,
QTextCursor::KeepAnchor);
//move cursor to end of line without anchor, selecting text between}
void MainWindow::handleSelect(){
ListWindow->moveCursor(QTextCursor::StartOfLine); //move cursor and anchor to start of line
ListWindow->moveCursor(QTextCursor::EndOfLine, QTextCursor::KeepAnchor); //move cursor to end of line without anchor, selecting text between
}
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?
Bookmarks