You seem to have problems understanding how a pointer works.
*CorrectID = ui->lineEdit_CurrentID->text().toInt();
That code dereferences your pointer and assigns the value on the right side to the address it points at. Do to so, it already needs to point at some address. Right now, given the code you posted in your "answer", it would not have.
You need to assign an address to your pointer, otherwise, it might contain random nonsense that easily leads to a crash. You can do this like that:
CorrectId = new int;
Which creates a new variable on the heap and uses that address, although that is most likely not a valid ID.
Or given your "answer" code, you could create a stack variable in the scope of your main and set the pointer towards it, although that wouldn't be a good design.
That said, probably more important: Try to avoid global variables. I don't know your design, therefore I can't tell you how you should do it, but you having that pointer being a global variable is a red flag to me. Having an ID that can be manipulating from all directions is also, even if you'd use injection instead. Most likely, you should create a class which stores CorrectID as a member and thus takes ownership of it. A reference to this class is shared by injection and any manipulation of the member is done over the interface of the class. Now again, I don't know your big design, but in most cases, this will be the way to go.
Given your other code, it could be simply done by making it a member of your main window. Or you have some other class that controls things to which the main window has a pointer to. Best would be if you gave us context.
A possible layout of your project:
class IDController
{
private:
int _ID;
public:
void setID(int ID) { _ID = ID; }
const int& ID() const { return _ID; }
};
int main(int argc, char *argv[])
{
IDController controller;
QApplication a(argc, argv);
MainWindow w(&a, &IDController);
...
}
class MainWindow : public QMainWindow
{
...
private:
IDController* controller;
...
MainWindow::MainWindow(QWidget* parent, IDController* controller) :
QMainWindow(parent),
controller(controller)
ui(new Ui::MainWindow)
{
...
void MainWindow::on_pushButton_clicked()
{
controller->setID(6);
}
The name IDController should be replaced by some more organical name, some class that the ID belongs to. Note that I do not initialize _ID, which is bad. IDController should have some defined constructor. If the ID is something very volatile, one might decide to remove the getter and setter from the controller and make it public, but most likely, instead you want to extent the setter and getter to do some additional things (like verifying that a given ID is valid).