Results 1 to 6 of 6

Thread: How can I create a widget list as Qt Designer?

  1. #1
    Join Date
    Apr 2009
    Posts
    132
    Thanks
    67
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Red face How can I create a widget list as Qt Designer?

    I'd like to create in my main window something like a widget list (Qt desgigner has what I want) with different sections. Which componets or widgets should I use? (Can I do it without creating new components?)
    With scrollbar and dockwindow (this one is easy to add). Filter would be nice. I guess is just another componet.



    Thanks a lot for your help.

  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: How can I create a widget list as Qt Designer?

    You could search the forum more. This had been discussed as far as I remember,

    Hint 1 : QTreeView with delegates.
    Hint 2: Dig in Designer code if available

  3. #3
    Join Date
    Apr 2009
    Posts
    132
    Thanks
    67
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How can I create a widget list as Qt Designer?

    Quote Originally Posted by aamer4yu View Post
    You could search the forum more. This had been discussed as far as I remember,

    Hint 1 : QTreeView with delegates.
    Hint 2: Dig in Designer code if available
    Thanks for reply. Unfortunately I'm a beginner so I don't understand it very well.

    I only need several string lists with an icon every one, separeted by bold string (like the screenshot). Can I do it in a easy way? I don't know if I could delegate a class and add that functionality.

    Thanks for help. Any idea?

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: How can I create a widget list as Qt Designer?

    Quote Originally Posted by ricardo View Post
    Thanks for reply. Unfortunately I'm a beginner so I don't understand it very well.
    Then please use the Newbie section of this board. You are welcome.

    I only need several string lists with an icon every one, separeted by bold string (like the screenshot). Can I do it in a easy way?
    Yes, there is an easy way: QTreeView with delegates!

    I don't know if I could delegate a class and add that functionality.
    Look, the designer is a great tool, but it can't do anything for you. Still Qt is "part" of the C++ programming language, so you have to be a little knowledge of that if you want to work with it. For the delegate thing look in the docks, or as aamer4yu said ind the sources of designer.

  5. The following user says thank you to Lykurg for this useful post:

    ricardo (2nd May 2009)

  6. #5
    Join Date
    Apr 2009
    Posts
    132
    Thanks
    67
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How can I create a widget list as Qt Designer?

    OK. Thanks, I will read about that.

    Well, this is what I was looking for:
    http://www.qtcentre.org/forum/f-qt-p...ner-14912.html
    Last edited by ricardo; 2nd May 2009 at 09:46.

  7. #6
    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: How can I create a widget list as Qt Designer?

    yea, using pushbutton looks good... but u have to make extra connections for buttons clicked... isnt it ?
    With delegates you wont have to both so much...
    Just made a simple delegate u can start with...
    Qt Code:
    1. class TreeDelegate : public QItemDelegate
    2. {
    3. protected:
    4. virtual void paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const
    5. {
    6. if(index.child(0,0).isValid())
    7. {
    8. painter->setPen(Qt::blue);
    9. //painter->drawRect(option.rect);
    10. opt.rect = option.rect;
    11. qApp->style()->drawControl(QStyle::CE_PushButton, &opt,painter);
    12. }
    13. QItemDelegate::paint(painter,option,index);
    14. }
    15. virtual void drawCheck ( QPainter * painter, const QStyleOptionViewItem & option, const QRect & rect, Qt::CheckState state ) const {};
    16. };
    To copy to clipboard, switch view to plain text mode 
    You will need to call view->setItemDelegate(new TreeWidgetDelegate());
    thats it.
    also to achieve expand/collapse on single click like in designer, you can connect itemClicked signal to some function of yours..
    Like ,,,
    Qt Code:
    1. MainWindow::MainWindow()
    2. {
    3. ui.setupUi(this);
    4. ui.treeWidget->expandAll();
    5. connect(ui.treeWidget,SIGNAL(itemPressed(QTreeWidgetItem*,int)),this,SLOT(itemClicked(QTreeWidgetItem*)));
    6. ui.treeWidget->setItemDelegate(new TreeDelegate());
    7. ui.treeWidget->setRootIsDecorated(false);
    8. }
    9. void MainWindow::itemClicked(QTreeWidgetItem* item)
    10. {
    11. item->setSelected(false);
    12. item->setExpanded(!item->isExpanded());
    13. }
    To copy to clipboard, switch view to plain text mode 

    One thing more to be noted is in Qt 4.5 designer has icon view too... so not sure if they have used tree widget for that... May be they might have used treewidget, with one parent one child... and the child must be QListWidget...
    Last edited by aamer4yu; 3rd May 2009 at 13:16.

  8. The following user says thank you to aamer4yu for this useful post:

    ricardo (5th May 2009)

Similar Threads

  1. add an apps to the designer widget box
    By adamatic in forum Qt Tools
    Replies: 1
    Last Post: 5th March 2009, 06:31
  2. how to create something like widget box in qt designer
    By gregsan in forum Qt Programming
    Replies: 3
    Last Post: 18th July 2008, 15:21
  3. Replies: 1
    Last Post: 22nd October 2007, 02:04
  4. Replies: 2
    Last Post: 12th July 2007, 09:55
  5. How to create pop up widgets in designer.
    By gsQT4 in forum Qt Tools
    Replies: 1
    Last Post: 25th May 2006, 16:40

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.