Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]QFile and QTextStream Question
Qt 6.12 LTS is out! See what's new in the release blog

[SOLVED]QFile and QTextStream Question

Scheduled Pinned Locked Moved General and Desktop
24 Posts 3 Posters 20.2k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #11

    hi Lam,

    Could you please describe more?
    I am too new to Qt ..

    1 Reply Last reply
    0
    • IamSumitI Offline
      IamSumitI Offline
      IamSumit
      wrote on last edited by
      #12

      Hii.
      void QAbstractSlider::valueChanged ( int value ) [signal]
      This signal is emitted when the slider value has changed, with the new slider value as argument.
      http://qt-project.org/doc/qt-4.8/qabstractslider.html#valueChanged
      This is the signal you need to connect with your slot .just like when you connect your QPushButton's clicked signal to it's Slot_clicked();
      hope you know signal and slot
      .

      Be Cute

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #13

        I try it now,
        Feel like, i am going to fail my school Final Year Project ...

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #14

          So, i need to create another .cpp and .h file for this?

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #15

            because i am now writing this in a function
            :
            @void Dialog::getValue()
            {
            int h_slide1 = ui->hueSlide1->value();
            QFile valueHSV("/home/pi/valueHSV/hsv.txt");
            if(!valueHSV.open(QIODevice::WriteOnly| QIODevice::Text)){
            qDebug() << "File not able to open" << endl;
            return;
            }
            QTextStream hsv(&valueHSV);
            hsv << h_slide1;
            qDebug() << "Value ="<<h_slide1
            valueHSV.close();
            }@

            1 Reply Last reply
            0
            • IamSumitI Offline
              IamSumitI Offline
              IamSumit
              wrote on last edited by
              #16

              yes you can add another .h and .cpp file .inheriting QWidget class.

              Be Cute

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #17

                i need to use MainWindow or Dialog?

                1 Reply Last reply
                0
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #18

                  the function in .h file should be under signals?

                  1 Reply Last reply
                  0
                  • IamSumitI Offline
                    IamSumitI Offline
                    IamSumit
                    wrote on last edited by
                    #19

                    hi
                    you can take a reference from the following link
                    http://www.codeprogress.com/cpp/libraries/qt/qProgressbarSetValueExample.php#.U7J--ZSSwb8

                    [Edited: Remember it is an old example using 4.7]

                    Be Cute

                    1 Reply Last reply
                    0
                    • ? Offline
                      ? Offline
                      A Former User
                      wrote on last edited by
                      #20

                      ermm.. this link not working..

                      1 Reply Last reply
                      0
                      • ? Offline
                        ? Offline
                        A Former User
                        wrote on last edited by
                        #21

                        The example i can understand, but whn the slider move, can i save the current value to a txt file?

                        1 Reply Last reply
                        0
                        • ? Offline
                          ? Offline
                          A Former User
                          wrote on last edited by
                          #22

                          Hi Lam,

                          I dont think your suggestion could work, i could not call ui into the function.

                          1 Reply Last reply
                          0
                          • IamSumitI Offline
                            IamSumitI Offline
                            IamSumit
                            wrote on last edited by
                            #23

                            [quote author="YDYD" date="1404207347"]ermm.. this link not working..[/quote]
                            link is perfectly working.

                            [quote author="YDYD" date="1404207723"]The example i can understand, but whn the slider move, can i save the current value to a txt file?[/quote]

                            yes that is why this signal is given.

                            [quote author="YDYD" date="1404207829"]Hi Lam,

                            I dont think your suggestion could work, i could not call ui into the function.[/quote]

                            the example does not use Qt designer Widget it is taking on run time.

                            I think the problem is you have to understand the basics first like
                            @
                            creating .h and .cpp file inheriting QWidget/QMainWindow or Qdialog.
                            SIGNAL and SLOT
                            and many more thing.
                            @

                            Be Cute

                            1 Reply Last reply
                            0
                            • ? Offline
                              ? Offline
                              A Former User
                              wrote on last edited by
                              #24

                              ok =)
                              Thank you.
                              I am very rush because i was only given 2weeks time to port a project coding into Qt ...

                              Sorry for troubling u all
                              and Thanks a lot

                              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
                              • Unsolved