Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Writting from a spinBox to a file .txt
Forum Updated to NodeBB v4.3 + New Features

Writting from a spinBox to a file .txt

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 795 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aLMT
    wrote on last edited by
    #1

    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) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);

    int nombre=ui->spinBox->value();
    texte=QString::number(nombre);
    

    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }

    void MainWindow::on_pushButton_clicked()
    {
    QFile file("out.txt");
    if (!file.open(QIODevice::WriteOnly))
    return;

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

    }
    @

    Thank you a lot for your answer,
    Arnaud

    1 Reply Last reply
    0
    • A Offline
      A Offline
      aLMT
      wrote on last edited by
      #2

      Hi guys again,

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

      See ya

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ambershark
        wrote on last edited by
        #3

        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?

        My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved