Results 1 to 2 of 2

Thread: Multiple Window Class Variables

  1. #1
    Join Date
    Jun 2013
    Posts
    46
    Thanks
    24
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Post Multiple Window Class Variables

    Qt colleagues

    I have multiple windows(ControlWindow, NewWindow)

    How do I pass variables between windows (From ControlWindow to NewWindow & NewWindow to ControlWindow)

    ControlWindow CreateNewWindow button creates a newWindow.
    ControlWindow also has an upload image Button that loads an image in the label of the new window.
    ControlWindow holds the name of image(QString) & the QImage

    In my newWindow Constructor
    Qt Code:
    1. MainWindow TempMain; //probably because im creating a new instance of mainWindow variables are blank!
    2. //But that than how do I call the getter Functions of mainWindow from newWindow?
    3. //Nothing loads, the QString & Qimage is blank?
    4. QString tempName = TempMain.getName();
    5. QImage tempImage = TempMain.getImage();
    6.  
    7. tempImage .load(tempName);
    8. ui->labelImage->setPixmap(QPixmap::fromImage(tempImage));
    To copy to clipboard, switch view to plain text mode 

    Help please. Ideas

    Signals and slots, Maybe?
    Last edited by 2lights; 16th July 2013 at 12:47. Reason: updated contents

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Multiple Window Class Variables

    You can of course always use signal/slot.

    Also, if MainWindow holds a pointer to your new window, than it can access all its public methods, so it can call setters and getters.

    Cheers,
    _

Similar Threads

  1. Replies: 10
    Last Post: 6th April 2011, 11:05
  2. Replies: 2
    Last Post: 9th March 2011, 13:27
  3. Replies: 2
    Last Post: 12th June 2010, 03:21
  4. Multiple definition of a variable?
    By T0bi4s in forum Newbie
    Replies: 5
    Last Post: 14th January 2010, 23:13
  5. Replies: 6
    Last Post: 4th April 2006, 08:13

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.