Results 1 to 2 of 2

Thread: Problem when change widget to another widget

  1. #1
    Join Date
    Nov 2010
    Posts
    4
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Question Problem when change widget to another widget

    Have a following code:

    Class MainWindow
    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow)
    4. {
    5. ui->setupUi(this);
    6. MainScreem *mainScreem = new MainScreem();
    7. ui->scrollPrueba->setWidget(mainScreem);
    8. }
    To copy to clipboard, switch view to plain text mode 

    Class MainScreem
    Qt Code:
    1. MainScreem::MainScreem(QWidget *parent) : QWidget(parent)
    2. {
    3. QVBoxLayout *vLayout = new QVBoxLayout(this);
    4. QListWidget *listWidget = new QListWidget();
    5. vLayout->addWidget(listWidget);
    6. QObject::connect(listWidget, SIGNAL(itemClicked(QListWidgetItem*)), this,
    7. SLOT(detailSlot(QListWidgetItem*)));
    8. for(int i=0; i<5;i++)
    9. {
    10. item->setText(QObject::tr("List Item: %1").arg(i));
    11. listWidget->addItem(item);
    12. }
    13. }
    14.  
    15. void MainScreem::detailSlot(QListWidgetItem *item)
    16. {
    17. DetailScreem *detail = new DetailScreem();
    18. delete this->layout();
    19. QVBoxLayout *vLayout2 = new QVBoxLayout(this);
    20. vLayout2->addWidget(detail);
    21. }
    To copy to clipboard, switch view to plain text mode 

    Class DetailScreem
    Qt Code:
    1. DetailScreem::DetailScreem(QWidget *parent) : QWidget(parent)
    2. {
    3. QVBoxLayout *vLayout = new QVBoxLayout(this);
    4. QLabel *label = new QLabel("Hola Mundo");
    5. vLayout->addWidget(label);
    6. }
    To copy to clipboard, switch view to plain text mode 

    My problem is that the MainScreem widget is behind the DetailsScreem widget. That is, the scrollPrueba not replace or not updated, seeing two widgets one after the other.

    If someone could help me with this problem so that the DetailsWidget is drawn but the MainScreem widget does not appear ago.

    I appreciate the cooperation.

    Thank you very much.

  2. #2
    Join Date
    Apr 2010
    Posts
    5
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem when change widget to another widget

    hi
    its very easy...let me be clear with your problem...you have two widgets and you have named it has Main screen and detail screen and you want to show the latter one after the previous one without showing the mainscreen widget.


    no need to code so much..this is just linking of forms and its very simple buddy
    follow these simple steps
    1.create 2 forms and name as you like
    2.keep one push button and name it as "next" so that u can go to next button and write slot for this button


    I need some effort from you also so i m not giving u the full solution...try out if u cant get it...i m there to help you

    bye take care

Similar Threads

  1. How to change a widget to other widget in layout?
    By Kevin Hoang in forum Qt Programming
    Replies: 2
    Last Post: 20th March 2010, 10:55
  2. Replies: 2
    Last Post: 22nd February 2010, 08:48
  3. how to change the color of a top widget ?
    By feiyinziiu in forum Qt Programming
    Replies: 2
    Last Post: 4th December 2009, 02:41
  4. Change widget type
    By drescherjm in forum Qt Tools
    Replies: 2
    Last Post: 16th April 2009, 02:03
  5. Hide widget, but not change layout
    By dimaz in forum Qt Programming
    Replies: 3
    Last Post: 21st November 2008, 14:32

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.