[Qt-interest] Best way to implement a group of Widgets
Abhishek Patil
abhishekworld at gmail.com
Sat Feb 6 09:00:16 CET 2010
Rohan Prabhu wrote:
> I want to implement a QWidget derived class which acts like a group of
> widgets. I just need ideas on how to do it best. My concerns currently
> are:
>
> 1. How to implement the paintEvent()? Inside the paintEvent() of my
> Parent Widget, do I call the paintEvent() of every other child widget?
>
Bit confusing but what I understand is every child widget will have
there own paintEvent ()
so as u say update in parent widget every child will automatically
update itself..
> 2. How do I handle positioning? I want that each child widget be
> positioned by nothing but x and y co-ordiantes relative to the parent
> widget. How do I go about doing this?
>
If you have such a situation
MyParentWdiget::MyParentWidget(QWidget* parent)
:QWidget(parent)
{
Mychild child = new Mychld(this);
* //here you can do this
child->setGeometry(this->x(),this->y(), 100,100);
*}
or in child class
MyChildWdiget::MyChildWidget(QWidget* parent)
:QWidget(parent)
{
* this->setGeometry(parent->x(), parent->y(), parent->width(),
parent->height());*
}
Note: any one of them is will do your job
> 3. Each of my child widget will be QWidget derivates, not QWidgets, so
> how do I implement the 'Widget stack' as Qt calls it. I also need to
> implement it properly so that a widget higher in the stack goes on the
> front or back of other widgets as appropriate.
>
I didnt understand this but if you are talking about QStackWidget so its
simple just have a look http://doc.trolltech.com/4.6/qstackedwidget.html
> 4. Can I make my child widgets draggable?
>
>
I am not sure but i think yes u can ....
> I have tried doing a little thinking from my side. But, I've mostly
> thought of a parent class with a QVector<CmWidget*> to hold my widgets
> and I'm absolutely clueless of how to implement the paintEvent().
>
> Any help is truly appreciated.
>
> regards,
> rohan
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
--
Abhishek Patil | http://thezeroth.wordpress.com
+91-9620022244 | abhishek at thezeroth.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100206/f3263703/attachment.html
More information about the Qt-interest-old
mailing list