Results 1 to 2 of 2

Thread: gridlayout unwanted display

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2013
    Location
    Hyderabad,Bangalore,India
    Posts
    70
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    8
    Thanked 4 Times in 4 Posts

    Default gridlayout unwanted display

    Hi below is my application
    LoadApplication loads a set of pushbuttons in Gridlayout
    nss1.jpeg is the window once LoadApplication is completed.

    Qt Code:
    1. #include "mainwindow.h"
    2. #include <QtGui>
    3.  
    4. void MainWindow::LoadApplication()
    5. {
    6. int a[] = {0,0,0,1,1,1,2,2,2};
    7. int b[] = {3,6,9,3,6,9,3,6,9};
    8.  
    9. if(button[0]){
    10. delete button[0],button[0]=NULL;
    11. delete previewGroupBox,previewGroupBox=NULL;
    12. delete previewLayout,previewLayout=NULL;
    13. delete calendar,calendar=NULL;
    14.  
    15. if (Gh)
    16. delete Gh,Gh=NULL;
    17. }
    18.  
    19. if(!Gh){
    20. Gh = new QGridLayout();
    21. display -> setLayout(Gh);
    22. }
    23.  
    24. for(int i = 0; i < 9; i++)
    25. {
    26. button[i] = new QPushButton(QIcon("qt4.png"),NULL,this);
    27. button[i] -> setIconSize(button[i]->rect().size());
    28. Gh -> addWidget(button[i],a[i],b[i],1,3);
    29. button[i] -> setGeometry(a[i],b[i],100,100);
    30. button[i] -> setMaximumSize(100,100);
    31. connect(button[i],SIGNAL(clicked()),this,SLOT(fun()));
    32. }
    33. }
    To copy to clipboard, switch view to plain text mode 


    the fun is used to delete the layouts and buttons so that the calendar can be launched.
    so nss2.jpeg is window after this fun is called.

    but here i observe some strange thing .
    even after deleting buttons i can see some buttons in the background.
    in the attached jpeg this can be seen clearly..

    i need help in understanding , from where those buttons are coming.

    Qt Code:
    1. //void MainWindow ::fun(int i)
    2. void MainWindow ::fun()
    3. {
    4.  
    5. for(int i=0;i<9;i++)
    6. if(button[i])
    7. delete button[i],button[i]=NULL;
    8. if (Gh)
    9. delete Gh,Gh=NULL;
    10.  
    11. Gh = new QGridLayout;
    12. display->setLayout(Gh);
    13. createPreviewGroupBox();
    14. Gh->addWidget(previewGroupBox, 0, 0);
    15.  
    16. button[0] = new QPushButton(QIcon("qt4.png"),NULL,this);
    17. Gh -> addWidget(button[0],3,2,1,3);
    18. button[0] -> setGeometry(3,2,100,100);
    19. button[0] -> setMaximumSize(50,50);
    20. connect(button[0],SIGNAL(clicked()),this,SLOT(LoadApplication()));
    21.  
    22. }
    To copy to clipboard, switch view to plain text mode 

    this is for standard calendar widget

    Qt Code:
    1. void MainWindow::createPreviewGroupBox()
    2. {
    3. previewGroupBox = new QGroupBox(tr("Preview"));
    4.  
    5. calendar = new QCalendarWidget;
    6. calendar->setMinimumDate(QDate(1900, 1, 1));
    7. calendar->setMaximumDate(QDate(3000, 1, 1));
    8. calendar->setGridVisible(true);
    9.  
    10. connect(calendar, SIGNAL(currentPageChanged(int,int)),
    11. this, SLOT(reformatCalendarPage()));
    12.  
    13. previewLayout = new QGridLayout;
    14. previewLayout->addWidget(calendar, 0, 0, 0);//Qt::AlignCenter);
    15. previewGroupBox->setLayout(previewLayout);
    16. }
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images

Similar Threads

  1. Unwanted white border
    By Jake123 in forum Newbie
    Replies: 1
    Last Post: 26th January 2013, 12:16
  2. QTreeView and unwanted scrollbar
    By theprobe in forum Qt Programming
    Replies: 2
    Last Post: 12th January 2011, 08:19
  3. QGraphicsView unwanted margin
    By hheld in forum Qt Programming
    Replies: 4
    Last Post: 3rd January 2011, 17:16
  4. Unwanted padding on QWidget
    By etru1927 in forum Qt Programming
    Replies: 4
    Last Post: 7th August 2008, 07:42
  5. QMdiArea unwanted actvation
    By fullmetalcoder in forum Qt Programming
    Replies: 7
    Last Post: 12th November 2007, 07:09

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.