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. I have a simple question.
Qt 6.11 is out! See what's new in the release blog

I have a simple question.

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 611 Views
  • 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 Offline
    S Offline
    streetsoul
    wrote on last edited by
    #1

    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
    0
    • hskoglundH Offline
      hskoglundH Offline
      hskoglund
      wrote on last edited by hskoglund
      #2

      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
      4

      • Login

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