QString problem



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



  • make it a member variable of MainWindow



  • This post is deleted!


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


  • Qt Champions 2017

    @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
    }
    


  • @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();
    }
    


  • @Gojir4 When I do this my program crashing.



  • Problem solved.


  • Qt Champions 2017

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.