Results 1 to 7 of 7

Thread: How to actually connect variables to the GUI ?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    62
    Thanked 260 Times in 246 Posts

    Default Re: How to actually connect variables to the GUI ?

    The code depends on what method you used to integrate the .ui file in C++ code, there are many ways to achieve that (i personally prefer to use a private pointer to the ui class, that is because the code is better encapsulated that way, and disadvantage is that you most likely will need to code more signals and slots to keep that pointer private )
    So the code can be:
    Qt Code:
    1. void MainWindow:: on_button_clicked()
    2. {
    3. // this depends on how you integrate the .ui file
    4. // example if ui is a pointer
    5. ui->YourButtonName->setText("Hello World!");
    6. }
    To copy to clipboard, switch view to plain text mode 
    And one more thing, i really advise you ignore the feature called auto-connect (the one based on naming the slots like this on_ObjectName_SignalName() ) at least at the beginning learn how and when to do the connections and when you are comfortable with signal/slots "mechanism", decide if you will use auto-connect or not.

    LE: The thing with the signal is that you will not implement the signal, you just declare the signals something like this signals: void mySignal(int x); and you don't write something like void signal(int x) {//... code; }

    You just "call" the signal using: emit mySignal(10);
    Last edited by Zlatomir; 14th November 2010 at 21:23.

Similar Threads

  1. Casting variables
    By axisdj in forum Newbie
    Replies: 1
    Last Post: 6th September 2010, 17:00
  2. how to share variables
    By sksingh73 in forum Newbie
    Replies: 4
    Last Post: 2nd July 2010, 04:54
  3. Replies: 16
    Last Post: 16th February 2010, 13:17
  4. environmental variables
    By mohanakrishnan in forum Newbie
    Replies: 4
    Last Post: 26th October 2009, 09:43
  5. Replies: 4
    Last Post: 10th November 2006, 15:38

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.