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. QString to char*
Forum Updated to NodeBB v4.3 + New Features

QString to char*

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 4 Posters 4.3k Views 2 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.
  • DejavuD Offline
    DejavuD Offline
    Dejavu
    wrote on last edited by Dejavu
    #4

    Thank's a lot for help. How i can get a access to values in QList to edit characters or counter?

    1 Reply Last reply
    0
    • jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #5

      See here http://doc.qt.io/qt-5/qlist.html

      list[i] = ...
      

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • DejavuD Offline
        DejavuD Offline
        Dejavu
        wrote on last edited by
        #6

        Thanks a lot to all and thank you so much @Wieland

        ? 1 Reply Last reply
        0
        • DejavuD Dejavu

          Thanks a lot to all and thank you so much @Wieland

          ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #7

          @Dejavu You're welcome ;-)

          DejavuD 1 Reply Last reply
          1
          • ? A Former User

            @Dejavu You're welcome ;-)

            DejavuD Offline
            DejavuD Offline
            Dejavu
            wrote on last edited by
            #8

            @Wieland sorry for new stupid question)
            When I try to display the text in textEdit I got this error: C2227: left of '->textEdit' must point to class/struct/union/generic type

            void printYourHomework( const YourList &list)
            {
            double *mynum, *freq, diap;
            double *cum_freq;
            double temp_cum = 0.0;
            for (int i=0; i<list.size(); i++)
            {
            mynum = new double[i];
            freq = new double[i];
            cum_freq = new double[i];
            }
            for (int i=0; i<list.size(); i++) {
            const YourPair pair = list.at(i);
            MainWindow::ui->textEdit->append(QString("'%1' - %2").arg(pair.first).arg(pair.second));
            mynum[i] = pair.second;
            freq[i] = mynum[i]/18;
            MainWindow::ui->textEdit->append(QString::number(freq[i], 'f', 8));
            }

            1 Reply Last reply
            0
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #9

              @Dejavu said:

              MainWindow::ui->textEdit->

              That might be the reason.
              You cannot access mainwindows UI outside of mainwindow.

              So easy fix is to move the functions to mainwindow
              ( remember to add it to the mainwin.h file too)

              YourList MainWindow::computeYourHomework(const QString &s) {
              ..
              ui->textEdit->append(xxx
              }

              1 Reply Last reply
              1
              • DejavuD Offline
                DejavuD Offline
                Dejavu
                wrote on last edited by
                #10

                @mrjj thank you for the reply
                I add it to mainwin file:

                private slots:
                YourList computeYourHomework(const QString &s);
                void printYourHomework(const YourList &list);

                and then i received errors:
                http://prntscr.com/b2hmp6

                I add function in mainwindow.cpp.

                mrjjM 1 Reply Last reply
                1
                • DejavuD Dejavu

                  @mrjj thank you for the reply
                  I add it to mainwin file:

                  private slots:
                  YourList computeYourHomework(const QString &s);
                  void printYourHomework(const YourList &list);

                  and then i received errors:
                  http://prntscr.com/b2hmp6

                  I add function in mainwindow.cpp.

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #11

                  @Dejavu
                  Hi
                  Maybe dont list it as slots. ( not the real error)
                  just put it under
                  private:

                  Then u also need to make sure it knows
                  YourList type
                  so u must move that over mainwindow class
                  or put in its on file and
                  #include "YourList .h"

                  DejavuD 1 Reply Last reply
                  1
                  • mrjjM mrjj

                    @Dejavu
                    Hi
                    Maybe dont list it as slots. ( not the real error)
                    just put it under
                    private:

                    Then u also need to make sure it knows
                    YourList type
                    so u must move that over mainwindow class
                    or put in its on file and
                    #include "YourList .h"

                    DejavuD Offline
                    DejavuD Offline
                    Dejavu
                    wrote on last edited by
                    #12

                    @mrjj thank u so much.

                    I fix this problem. I just add #include in header and now it works.
                    Thanks a lot :)

                    mrjjM 1 Reply Last reply
                    1
                    • DejavuD Dejavu

                      @mrjj thank u so much.

                      I fix this problem. I just add #include in header and now it works.
                      Thanks a lot :)

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #13

                      @Dejavu
                      Super :)

                      1 Reply Last reply
                      1

                      • Login

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