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. How I can access my label?

How I can access my label?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.7k 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.
  • D Offline
    D Offline
    dwsld
    wrote on last edited by
    #1

    I want to change the text in my label but I can`t use ui outside of MainWindow::?How to do this?

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      It's a pointer, you can pass it around as any other variable - copy, make a function parameter, create a signal-slot connection... you choose.
      A kinda basic approach would be to crate public "setter" method in your MainWindow and call it from wherever you want it.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dwsld
        wrote on last edited by
        #3

        Can you write me a code?

        1 Reply Last reply
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Of a setter function? C'mon... ;)
          @
          void MainWindow::setSomeLabelText(QString text)
          {
          ui.label->setText(text);
          }
          @

          1 Reply Last reply
          0

          • Login

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