How to Remove Line Endings From QString
- 1). Click “Start,” “All Programs” and “Qt Creator.” Click “File” and “New” to create a Qt application. Enter a name for the application. Click "Browse" and specify a location for the project files, then click “Next.”
- 2). Select required modules such as QtCore and GtGui. QtCore module contains core non-GUI functionality, while GtGui module extends QtCore module with GUI features. Click “Finish” to enter the development interface.
- 3). Click “mainwindow.ui” under “Projects” text. Click the “Buttons” icon to expand the buttons section on the Toolbar. Select “Push Button” and drag and drop it on the blank area of the design form. Add a text label the same way.
- 4). Click the “Edit Signals/slots” icon on the top of the window. Click “Closed()” on the “Pushbutton” section in the “Configure Connection” window. Click the “Edit” button to enter the edit window. Click the “+” button to add a new slot named “buttonclick.” Click “OK.”
- 5). Click the “mainwindow.h” file to enter the code interface. Declare a public slot via code:
Public slots:
Void buttonclick(); - 6). Click “mainwindow.cpp” and enter the following code to define the buttonclick slots:
Void MainWindow:buttonclick {
Private Qstring str1;
Str1=”hello world”
Str1.remove(6,5)
ui->label->setText(ui->str1)
}.
Click the “Build” icon to build the application. This will remove the five characters at the end of str1.
Source...