Results 1 to 2 of 2

Thread: [PyQt4]—Visual display of a register

  1. #1
    Join Date
    Jan 2012
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default [PyQt4]—Visual display of a register

    Hi there,
    I use a micro-controller (uc) to control an asic (Application Specific Integrated Circuit). To do so, I wrote a PyQt4 application with a lot of qlineedit and qdoublespinbox and a few buttons. The buttons send to the uc the relevant information according to the content of lines and double spinboxes. The uc translates data to the asic protocol and talk to him. The communication is made through serial com using pyserial…
    Most of my registers are less than 8 bits long and the user enter the values with doublespinboxes. Though, I have a bunch of registers to control that are 32 and 192 bits long. I found a turnaround to easily enter the values but I would like to give the user a way to check and type values in an easier way.
    So far I use a QLineEdit with the following syntax for a 32 bits register:
    0:23,24,25:31=0,1,0
    which means from 0 to 23 the value is 0 then 1 for 24th bit and then 0 for 25 to 31
    of course, I wrote a small parser to convert the QLineEdit to serial bits that the uc understand.
    My idea is represented by the figure below :



    I would like, according to the above example, that all squares are red (Low state) except for 24 that should be green (Active state) !! Of course, that would be great if I could also toggle the states by clicking on the cells of this widget…
    My issue is that I just don’t know how to do that… I kinda see a turnaround using checkboxes but I don’t think I can put numbers in. I tried with a qtablewidget, not so successful ! maybe with toggle button and changing the background color according to its state… Really, I don’t know.
    Thanks in advance for your help.
    Have a good one,
    Olivier
    Attached Images Attached Images

  2. #2
    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: [PyQt4]—Visual display of a register

    For simplicity I would simply subclass a QWidget and do all the painting myself. It isn't so hard. Then reimp mousePressEvent and calculate which bit was clicked using the x coordinate of the mousepressevent. Alter private member "currentBit" and force a repaint by calling update()...

Similar Threads

  1. Register QtCreator on Win7?
    By weaver4 in forum Newbie
    Replies: 7
    Last Post: 5th April 2012, 23:30
  2. [PyQt4] PyQt4 + gcin issue
    By fieliapm in forum Installation and Deployment
    Replies: 0
    Last Post: 28th September 2010, 08:04
  3. Display records in Sqlite Pyqt4
    By viandante in forum Newbie
    Replies: 3
    Last Post: 24th September 2010, 20:22
  4. QtDesigner in Visual Stdio 2005 display error
    By osiris81 in forum Qt Tools
    Replies: 1
    Last Post: 25th February 2009, 15:15
  5. How to register a font with Qt?
    By Vadi in forum Qt Programming
    Replies: 5
    Last Post: 1st February 2009, 05:33

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.