Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Learning
  3. Qt in Education
  4. How can I operate ui widget in other CPP file?
Forum Updated to NodeBB v4.3 + New Features

How can I operate ui widget in other CPP file?

Scheduled Pinned Locked Moved Solved Qt in Education
5 Posts 2 Posters 2.6k Views 2 Watching
  • 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.
  • Season02S Offline
    Season02S Offline
    Season02
    wrote on last edited by A Former User
    #1

    I have create a qwidget project.And in the widget.cpp,I can ues such statement as "ui->listWidget->addItem("Test! ");" to interaction with there UI widget,but in my own cpp file,i can not do this.So what is the right way to use UI widget in othe cpp file?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mcosta
      wrote on last edited by
      #2

      HI and welcome to devnet,

      inside your class ui is private so you cannot access to it outside your class.
      If you need to change something outside your class you have to define a public method that changes your UI and call it from outside your class.

      Usually you can to it also using signals/slots

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      Season02S 1 Reply Last reply
      1
      • M mcosta

        HI and welcome to devnet,

        inside your class ui is private so you cannot access to it outside your class.
        If you need to change something outside your class you have to define a public method that changes your UI and call it from outside your class.

        Usually you can to it also using signals/slots

        Season02S Offline
        Season02S Offline
        Season02
        wrote on last edited by Season02
        #3

        @mcosta Thank you for your answer.One more thing i want to know is how to use signals/slots to do this ,or where i can get some coures/example about this?

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mcosta
          wrote on last edited by
          #4

          Hi,

          the Qt documentation has a lot of examples; you could start from here

          Once your problem is solved don't forget to:

          • Mark the thread as SOLVED using the Topic Tool menu
          • Vote up the answer(s) that helped you to solve the issue

          You can embed images using (http://imgur.com/) or (http://postimage.org/)

          Season02S 1 Reply Last reply
          1
          • M mcosta

            Hi,

            the Qt documentation has a lot of examples; you could start from here

            Season02S Offline
            Season02S Offline
            Season02
            wrote on last edited by
            #5

            @mcosta Thanks a lot,very thank you,I`m studing...

            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