Results 1 to 14 of 14

Thread: [PyQT] QDataWidgetMapper and Custom Widget

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2015
    Posts
    11
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default [PyQT] QDataWidgetMapper and Custom Widget

    Hi all,

    I'm trying to implement a treeview for my application and a qdatawidgetmapper to map the model data into a properties widget to facilitate the modification of the model data. So far, everything works pretty well (thanks to the M. Summerfield books). I can use easily QLineEdit, QSpinBox and QComboBox widgets in the properties widget. Now, I would like to add a custom widget (a "color" widget) in this properties wigdet. Basically, this custom widget is a QLineEdit which can not be manually edited (readOnly mode activated) and a QPushButton that opens a QColorDialog instance when the button is clicked. Basically, I choose a color from the QColorDialog instance, and the name of the color is programmatically written into the QLineEdit. But I don't know how to do the mapping between the model and the properties widget (both in vizualization and edition). I tried few things I found on the internet, but nothing worked and I'm stucked (the examples on the internet are not numerous).

    As an example would probably be clearer for you to understand my problemn, I've added a simple example in attachement of this message. The file contains several classes:
    - ProjectNode : basic class which represents the node of my treeview. Contains 2 attributes used for the mapping onto the properties widget : name and color
    - MyModel : custom model derived from QAbstractItemModel
    - myTreeView : custom treeview
    - PropertiesEditor : widget used to contain the data of the model (name and color)
    - MyTreeWidget : widget that combine the myTreeView and my Properties Editor
    - ColorWidget : custom widget evoked previously

    So my problem is : how to map the data of a model onto a custom widget?

    Any help would be greatly appreciated! Thanks in advance for your time

    Vincent
    Attached Files Attached Files

Similar Threads

  1. QDataWidgetMapper and custom widget - read value
    By Hostel in forum Qt Programming
    Replies: 3
    Last Post: 11th May 2013, 12:07
  2. Using QDataWidgetMapper with custom types
    By Zanyinj in forum Qt Programming
    Replies: 2
    Last Post: 25th August 2011, 09:42
  3. [PyQt] Creating custom widget
    By asik in forum Newbie
    Replies: 1
    Last Post: 2nd December 2010, 14:33
  4. Custom QLineEdit to store NULL with QDataWidgetMapper
    By certqt in forum Qt Programming
    Replies: 3
    Last Post: 9th November 2010, 13:15
  5. Custom Widgets to PyQt
    By prashant in forum Qt Programming
    Replies: 0
    Last Post: 24th September 2009, 15:17

Tags for this Thread

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.