Results 1 to 2 of 2

Thread: Using a form handle in another form

  1. #1
    Join Date
    Dec 2006
    Posts
    211
    Thanks
    27
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question Using a form handle in another form

    Hi All,

    I am using Qt 4.2.2 on my Intel Mac.
    I have a MainWindow named MainForm which have a Widget ProgressBar.

    Now I m doing the following things.

    1. When I click on a toolbar icon in my MainForm and opening a Dialog(HeaderDlg).

    2. Then I click the ok button of the open Header dialog which is then accepted on Ok click.

    3. Then on that dialog accept I m creating a class Recovery object (Recovery r) in my MainForm class.

    4. and then calling some function of Recovery class with that objec in the MainForm class.

    5.Then it is doing some working in the recovery class now I want to show the value of a variable counter in the ProgressBar of MainForm class.

    I m declaring the Form Pointer and using it as--

    extern void *MainFormPtr;
    MainForm *mainform1=(MainForm*)MainFormPtr;
    mainform->progressBar->setValue(counter);

    Now it is not working but when I debug the program the mainform pointer value is 0X00.
    But If I declare the object as

    MainForm *mainform=new MainForm(0);

    Then it is giving pointer value but ot showing the increase value of Progress bar .


    If anybody knows what I m doing wrong then plz tell me.

    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Using a form handle in another form

    I think you should use signals and slots instead of such complex constructions. Especially get rid of that global pointer.

Similar Threads

  1. [Qt4.1] How to insert an image inside a Form?
    By Gonzalez in forum Qt Tools
    Replies: 5
    Last Post: 23rd September 2008, 11:20
  2. form setting
    By mickey in forum Qt Tools
    Replies: 5
    Last Post: 27th September 2006, 00:28
  3. How to create an Insert/Submit button for a form.
    By fnmblot in forum Qt Programming
    Replies: 5
    Last Post: 4th August 2006, 16:18
  4. Menubar in mainwindow form
    By Draximillian in forum Qt Tools
    Replies: 5
    Last Post: 13th April 2006, 02:26
  5. Connecting slots/signals in subclassed form
    By qball2k5 in forum Qt Programming
    Replies: 2
    Last Post: 7th March 2006, 16:01

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.