Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Unsolved I have a simple question.

    General and Desktop
    2
    2
    262
    Loading More Posts
    • 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.
    • S
      streetsoul last edited by

      I have a simple question about qt programming.

      I want to using the ui file for add component.
      For example, add QLabel component by modify ui file.

      But text of label is need change.
      So I try code llike above...

      QLabel *label1 = ui->label;
      label->setText("change text");
      ui->setupUi(this);

      The result is crush.
      Crush message is above...

      "The program has unexpectedly finished.
      The process was ended forcefully."

      Can't I using this coding style??

      1 Reply Last reply Reply Quote 0
      • hskoglund
        hskoglund last edited by hskoglund

        Hi, ui->setupUi(this) creates all the stuff in your window, like the ui->label you're copying, so try to change the order of the statements to:

        ui->setupUi(this);
        QLabel *label1 = ui->label;
        label1->setText("change text");
        
        1 Reply Last reply Reply Quote 4
        • First post
          Last post