Results 1 to 4 of 4

Thread: Problem with setCentralWidget

  1. #1
    Join Date
    Sep 2008
    Posts
    38
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Problem with setCentralWidget

    I have in Konstruktor a setCentralWidget defined,
    Qt Code:
    1. MainWin::MainWin()
    2. {
    3. plotter = new Plotter; //Plotter is a custom Widget
    4. textEdit = new QTextEdit;
    5. setCentralWidget(plotter);
    6. }
    To copy to clipboard, switch view to plain text mode 
    in function changeToText(), and changeToPlotter(), I want to change the central Widget
    so write:
    Qt Code:
    1. MainWin::changeTotext()
    2. {
    3. setCentralWidget(textEdit);
    4. }
    5.  
    6. MainWin::changeToPlotter()
    7. {
    8. setCentralWidget(plotter);
    9. }
    To copy to clipboard, switch view to plain text mode 

    but at last i can`t change it, what`s wrong?

    thanks for your help!
    Last edited by jpn; 2nd September 2008 at 14:06. Reason: missing [code] tags

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with setCentralWidget

    How are u calling the changeToText and changeToPLotter functions ??

    I am not sure if you can set central widget twice.
    You may try this - set a QStackedWidget as central widget for the main window, and on the changeToText and changeToPLotter functions, set the text or plotter as the widget

  3. #3
    Join Date
    Sep 2008
    Posts
    38
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with setCentralWidget

    Quote Originally Posted by aamer4yu View Post
    How are u calling the changeToText and changeToPLotter functions ??

    I am not sure if you can set central widget twice.
    You may try this - set a QStackedWidget as central widget for the main window, and on the changeToText and changeToPLotter functions, set the text or plotter as the widget
    I call them like this:
    Qt Code:
    1. Void MainWin::creatActions()
    2. {
    3. ...
    4. connect(newAct, SIGNAL(triggered()), this, SLOT(changeToText()));
    5. ...
    6. }
    To copy to clipboard, switch view to plain text mode 

    it`s a litte complex,
    now i can see the TextEditor Window, if i call changeToText,
    but if i call changeToPlotter further, got a error Message..

    QStackedWidget is a good idea, i will try it .thanks
    Last edited by jpn; 2nd September 2008 at 14:08. Reason: missing [code] tags

  4. #4
    Join Date
    Sep 2008
    Posts
    38
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with setCentralWidget

    Quote Originally Posted by aamer4yu View Post
    You may try this - set a QStackedWidget as central widget for the main window, and on the changeToText and changeToPLotter functions, set the text or plotter as the widget
    hallo friend!

    now it Works! Thanks a lot!

Similar Threads

  1. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  2. Steps in solving a programming problem?
    By triperzonak in forum General Programming
    Replies: 8
    Last Post: 5th August 2008, 08:47
  3. problem with paint and erase in frame
    By M.A.M in forum Qt Programming
    Replies: 9
    Last Post: 4th May 2008, 20:17
  4. Tricky problem with ARGB widget / UpdateLayeredWindow
    By nooky59 in forum Qt Programming
    Replies: 3
    Last Post: 21st February 2008, 10:35
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.