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();

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

    DWORD MainWindow::injector()

  • Qt Champions 2018

    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 ?

  • Lifetime Qt Champion

    QString index10;
    in mainwinindow.h

    class QListWidgetItem; // new <<<<<
    class MainWindow : public QMainWindow
        explicit MainWindow(QWidget *parent = nullptr);
        QListWidgetItem *item10;    // new <<<<<  
        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 <<<<<<
    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.

  • Lifetime Qt Champion

    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.