Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Cant use ui on others functions
Forum Updated to NodeBB v4.3 + New Features

Cant use ui on others functions

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 1.3k Views 1 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.
  • J Offline
    J Offline
    jackraymund
    wrote on last edited by
    #1

    mainwindow.cpp
    http://wklej.to/3KynT
    mainwindow.h
    http://wklej.to/l7UAN
    why that code didnt work?
    @void pizda::aha()
    {
    MainWindow xd;
    xd.ui->label->setText("aha");
    }@
    no errors
    how can i resolve this?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tobias.hunger
      wrote on last edited by
      #2

      The mainwindow in pida::aha() is constructed in that method, you set the text and then it is destructed again, so it is never visible. It is most not the one you are actually showing in your main method.

      You could try to pass the Mainwindow pointer into the method or turn the MainWindow into a singleton or store it in a global variable (not nice) and access that in your method.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jackraymund
        wrote on last edited by
        #3

        yea, its work, but what i how i can do it when i want write it on class?

        like
        @class pizda
        {
        void aha(Ui::MainWindow* ok)
        {
        ok->label->setText("aha");
        }
        };@
        that isnt work

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jackraymund
          wrote on last edited by
          #4

          refresh

          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