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

QString problem

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 878 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.
  • jondoeJ Offline
    jondoeJ Offline
    jondoe
    wrote on last edited by
    #1

    Hello,
    This codes for my load button. I can use QString index10 in void MainWindow::on_load_clicked.

    void MainWindow::on_load_clicked()
    {
    QListWidgetItem *item10 = ui->listWidget_9->currentItem(); // process url
            QString index10 = ui->listWidget_9->item(sira.toDouble())->text();
            ui->label_3->setText(index10);
    }
    

    How can I use QString index10 here ? I want use QString index10 every where.

    DWORD MainWindow::injector()
    {
    here
    }

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      make it a member variable of MainWindow

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      jondoeJ 1 Reply Last reply
      1
      • jondoeJ Offline
        jondoeJ Offline
        jondoe
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • VRoninV VRonin

          make it a member variable of MainWindow

          jondoeJ Offline
          jondoeJ Offline
          jondoe
          wrote on last edited by
          #4

          @VRonin I did but still not working. Sorry Im beginner can you help me please with team wiever ?

          mrjjM Gojir4G 2 Replies Last reply
          0
          • jondoeJ jondoe

            @VRonin I did but still not working. Sorry Im beginner can you help me please with team wiever ?

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

            @jondoe
            Hi
            put
            QString index10;
            in mainwinindow.h

            class QListWidgetItem; // new <<<<<
            
            class MainWindow : public QMainWindow
            {
                Q_OBJECT
            public:
                explicit MainWindow(QWidget *parent = nullptr);
                ~MainWindow();    
            xxxxxxx
                QListWidgetItem *item10;    // new <<<<<  
            private:
                Ui::MainWindow *ui;
            };
            
            void MainWindow::on_load_clicked() {
              QListWidgetItem* item10 = ui->listWidget_9->currentItem(); // process url
              index10 = ui->listWidget_9->item(sira.toDouble())->text();// new <<<<<<
              ui->label_3->setText(index10);
            }
            
            DWORD MainWindow::injector()
            {
            index10  is known here now
            }
            
            1 Reply Last reply
            2
            • jondoeJ jondoe

              @VRonin I did but still not working. Sorry Im beginner can you help me please with team wiever ?

              Gojir4G Offline
              Gojir4G Offline
              Gojir4
              wrote on last edited by
              #6

              @jondoe Hi,

              I will suggest that you learn at least the basics of C++ before using Qt.

              Anyway, about your issue, in you case you can simply get the text from your label_3 control.

              DWORD MainWindow::injector()
              {
                  QString index10 = ui->label_3->text();
              }
              
              jondoeJ 1 Reply Last reply
              5
              • Gojir4G Gojir4

                @jondoe Hi,

                I will suggest that you learn at least the basics of C++ before using Qt.

                Anyway, about your issue, in you case you can simply get the text from your label_3 control.

                DWORD MainWindow::injector()
                {
                    QString index10 = ui->label_3->text();
                }
                
                jondoeJ Offline
                jondoeJ Offline
                jondoe
                wrote on last edited by
                #7

                @Gojir4 When I do this my program crashing.

                1 Reply Last reply
                0
                • jondoeJ Offline
                  jondoeJ Offline
                  jondoe
                  wrote on last edited by
                  #8

                  Problem solved.

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

                    Just for update:
                    It crashed as mainwindow member was
                    used with native API CreateThread
                    as callback. Which never works.

                    1 Reply Last reply
                    2

                    • Login

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