Important: Please read the Qt Code of Conduct -

Writting from a spinBox to a file .txt

  • Hello guys,

    I hope I wrote in the good section.

    Here is my problem, I want to write the value of a spinBox into a file .txt BUT what I actually get into my file is probably the address of the value (hexadecimal). I don't know what is wrong with my code (if it is when I get the value from the spinBox or if it is when I write it into the file)

    Here is the part of the code :

    @#include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include "secondwindow.h"

    MainWindow::MainWindow(QWidget *parent) :
    ui(new Ui::MainWindow)

    int nombre=ui->spinBox->value();


    delete ui;

    void MainWindow::on_pushButton_clicked()
    QFile file("out.txt");
    if (!

    QTextStream out(&file);
    out << nombre;
    second = new secondwindow(this);


    Thank you a lot for your answer,

  • Hi guys again,

    I was stupid, I fixed this problem by myself. Stupid mistake.

    See ya

  • Moderators

    Glad you fixed it. :) Sometimes I find just asking or posting about something kicks off the answer in my brain, lol.

    In order to help anyone else out that might view this looking for help could your post your fix for it and mark it as [SOLVED] in the title?

Log in to reply