I am trying to set the width of my html table to acquire the total width of my QTextEdit
by an inline stylesheet but the width of the table doesn't change. I've tried to give it values in the forms of percentages(%) and even pixels(px) but nothing changes.. Could you please have a look?
#!/usr/bin/env python2
import sys
from PySide import QtGui, QtCore
class MainWid(QtGui.QWidget):
htmlTable = '''<table border="1" style="width:100%"> <!-- XXX Nothing happens!! -->
<tr><th colspan="2">HEADER</th></tr>
<tr><td>name</td><td>value</td></tr>
<tr><td>name</td><td>value</td></tr>
</table>'''
def __init__(self, parent=None):
super(MainWid, self).__init__(parent)
self.initgui()
def initgui(self):
lay = QtGui.QVBoxLayout()
txt = QtGui.QTextEdit(self)
lay.addWidget(txt)
txt.setReadOnly(True)
txt.setHtml(self.htmlTable)
self.setLayout(lay)
self.show()
def main():
app = QtGui.QApplication(sys.argv)
wid = MainWid()
sys.exit(app.exec_())
if __name__=="__main__":
main()
I thank you all in advance.
See if this is what you are looking for:
htmlTable = ''' <table border="1" width="100%">
<tr><th colspan="2">HEADER</th></tr>
<tr><td>name</td><td>value</td></tr>
<tr><td>name</td><td>value</td></tr>
</table>
'''