Results 1 to 4 of 4

Thread: QGridLayout issue

  1. #1
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default QGridLayout issue

    Hi All,

    i m facing a very weird problem here. I have created a custom widget derived from QAbstractButton. i m adding five of these widgets to a gridlayout as they should be added.but the none of the widgets show up. never faced such a problem with grid layout. here is the code:

    Qt Code:
    1. #include "indiciacontainer.h"
    2. #include "indicia.h"
    3. #include <QGridLayout>
    4. IndiciaContainer::IndiciaContainer(QWidget *parent)
    5. : QWidget(parent)
    6. {
    7. resize(800, 500);
    8. indiciaGroup = new QButtonGroup(this);
    9. Indicia *indicia = new Indicia(this);
    10. Indicia *indicia2 = new Indicia(this);
    11. Indicia *indicia3 = new Indicia(this);
    12. Indicia *indicia4 = new Indicia(this);
    13. Indicia *indicia5 = new Indicia(this);
    14.  
    15. indiciaGroup->addButton(indicia);
    16. indiciaGroup->addButton(indicia2);
    17. indiciaGroup->addButton(indicia3);
    18. indiciaGroup->addButton(indicia4);
    19. indiciaGroup->addButton(indicia5);
    20.  
    21. indicia->setSvgPicture("d:\\browser.svg");
    22. indicia2->setSvgPicture("d:\\spheres.svg");
    23. indicia3->setSvgPicture("d:\\browser.svg");
    24. indicia4->setSvgPicture("d:\\shapes.svg");
    25. indicia5->setSvgPicture("d:\\bubbles.svg");
    26.  
    27. QGridLayout *grid = new QGridLayout(this);
    28. grid->setSpacing(5);
    29. grid->addWidget(indicia, 0, 0);
    30. grid->addWidget(indicia2, 0, 1);
    31. grid->addWidget(indicia3, 1, 0);
    32. grid->addWidget(indicia4, 1, 1);
    33. grid->addWidget(indicia5, 2, 0);
    34.  
    35. QRect rect = grid->cellRect(0,0);
    36. int x = rect.x();
    37. int y = rect.y();
    38. this->setLayout(grid);
    39. }
    To copy to clipboard, switch view to plain text mode 

    here is indicia.h :

    Qt Code:
    1. class Indicia : public QAbstractButton
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. Indicia(QWidget *parent);
    7. ~Indicia();
    8. void setText(QString imageLabel);
    9. void setSvgPicture(QString path);
    10.  
    11. protected:
    12. void mousePressEvent(QMouseEvent *event);
    13. void paintEvent(QPaintEvent *);
    14. private:
    15. Ui::IndiciaChoice ui;
    16. QSvgWidget *_svgWidget;
    17. };
    To copy to clipboard, switch view to plain text mode 

    any help is appreciated. i need a brisk solution to this

    thanks you guys!

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QGridLayout issue

    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    talk2amulya (26th February 2009)

  4. #3
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGridLayout issue

    thanks a lot..qt centre is heaven!

  5. #4
    Join Date
    Dec 2009
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGridLayout issue

    Hi

    a question

    I have a grid layout in a form ( ui manual designed ), with some items.

    I have to add to it a QSqltableview so I designed a frame, to put into it a QSqltableview .

    Frame has a horizontal layout working ( another item is into it )

    Problem is that QSqltableview doesn't resize itself like I think it should do.

    Thanks

    Bye

Similar Threads

  1. QGridLayout XY position
    By paule22 in forum Newbie
    Replies: 2
    Last Post: 9th August 2008, 18:42
  2. Delete a QGridLayout and New QGridLayout at runtime
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 5th November 2007, 13:01
  3. Qt 3.3 QGridLayout
    By ToddAtWSU in forum Qt Programming
    Replies: 2
    Last Post: 23rd February 2007, 17:40
  4. QGridLayout
    By ToddAtWSU in forum Qt Programming
    Replies: 5
    Last Post: 29th June 2006, 20:34
  5. QPixmap and QGridLayout
    By Talon_Karrde in forum Qt Programming
    Replies: 5
    Last Post: 22nd February 2006, 12:27

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.