Note that there are some explanatory texts on larger screens.

plurals
  1. POStrange treeview behaviour: strikeout text only if bold
    primarykey
    data
    text
    <p>I need to show some treeview item text striked out text into a QT treeview from Ruby. After some reading on QT documentation and much coding, I found that only when rendering font in bold, also the strikeout was rendered.</p> <p><img src="https://i.stack.imgur.com/pnt56.png" alt="Resulting treeview rendering."></p> <p>So I wonder, where I'm doing wrong? This is the code to achive the result shown above. Note as I set strikeout for every even row item. I'm using Ruby 1.8.7 and Qt 4.6.2 and qt4ruby 4.4.3-6 on Mandriva Linux.</p> <pre><code>require 'Qt4' require 'date' class MyStandardItem &lt; Qt::StandardItem def initialize(str = nil) super str end def data(role = Qt::UserRole + 1) return super(role) unless role == Qt::FontRole ret_val = Qt::Font.new() #parameters for "fromString":font family, pointSizeF, pixelSize, QFont::StyleHint, QFont::Weight, QFont::Style, underline, strikeOut, fixedPitch, rawMode ret_val.fromString "sans serif,-1,-1,0,0,0,0,0,0,0" case role when Qt::FontRole ret_val.setStrikeOut(true) if (index.row % 2) == 0 if index.column == 1 ret_val.weight = Qt::Font.Bold else ret_val.weight = Qt::Font.Normal end return Qt::Variant.fromValue(ret_val) end return ret_val end end Qt::Application.new(ARGV) do treeview = Qt::TreeView.new do model = Qt::StandardItemModel.new self head = [MyStandardItem.new "Qt v. #{Qt.version}"] head &lt;&lt; MyStandardItem.new("Ruby v. #{VERSION}") head &lt;&lt; MyStandardItem.new("Qt4Ruby v. 4.4.3-6 (Mandriva)") model.append_row head (1..10).each do |i| col0 = MyStandardItem.new 'some text' col0.check_state = ((i % 3) == 0)? Qt.Checked : Qt.Unchecked col0.checkable = true col0.editable= false col1 = MyStandardItem.new "line ##{i}" col2 = MyStandardItem.new((Date.today + i).strftime '%d/%m/%y') model.append_row [col0, col1, col2] end self.model = model show end exec end </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload