Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 5

Qt-interest Archive, April 2008
In QGridLayout setHorizontalSpacing(-1) does not work


Message 1 in thread

Hello
I want to insert QLables with boundary line to QGridLayout and makes it 
look like table.
when just setHorizontalSpacing(0), line thickness doubled between two 
adjacent labels.
so when I setHorizontalSpacing(-1), this means two lables overalp by 1 
pixel, it does not
produce right result. It restores to default value, 6.
In Qt docs, setHorizonSpacing() function can get int value. There is 
something wrong.
Can not negative values be used in parameter of setHorizonSpacing()?

thanks in advance

changwon


--
 [ signature omitted ] 

Message 2 in thread

The spacing between two items cannot be negative. If you set a negative 
horizontal spacing it will fall back to query for the styles' default 
horizntal spacing (which is 6 in some styles).

If I understand you correctly, you are trying to mimic grid lines by 
painting a frame along the edges of each label. This is not the 
recommended way of doing it, and explains why you get gridlines double 
as thick.

You can solve this in several ways, and the simplest way might be to use 
a table widget (see QTableWidget::setCellWidget()). It all depends on 
your use-case though.

Jan-Arve

changwon lee wrote:
> Hello
> I want to insert QLables with boundary line to QGridLayout and makes it 
> look like table.
> when just setHorizontalSpacing(0), line thickness doubled between two 
> adjacent labels.
> so when I setHorizontalSpacing(-1), this means two lables overalp by 1 
> pixel, it does not
> produce right result. It restores to default value, 6.
> In Qt docs, setHorizonSpacing() function can get int value. There is 
> something wrong.
> Can not negative values be used in parameter of setHorizonSpacing()?
> 
> thanks in advance
> 
> changwon
> 
> 
> -- 
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/


-- 
 [ signature omitted ] 

Message 3 in thread

Jan-Arve Sæther wrote:
> The spacing between two items cannot be negative. If you set a 
> negative horizontal spacing it will fall back to query for the styles' 
> default horizntal spacing (which is 6 in some styles).
>
> If I understand you correctly, you are trying to mimic grid lines by 
> painting a frame along the edges of each label. This is not the 
> recommended way of doing it, and explains why you get gridlines double 
> as thick.
>
> You can solve this in several ways, and the simplest way might be to 
> use a table widget (see QTableWidget::setCellWidget()). It all depends 
> on your use-case though.
>
> Jan-Arve
>
> changwon lee wrote:
>> Hello
>> I want to insert QLables with boundary line to QGridLayout and makes 
>> it look like table.
>> when just setHorizontalSpacing(0), line thickness doubled between two 
>> adjacent labels.
>> so when I setHorizontalSpacing(-1), this means two lables overalp by 
>> 1 pixel, it does not
>> produce right result. It restores to default value, 6.
>> In Qt docs, setHorizonSpacing() function can get int value. There is 
>> something wrong.
>> Can not negative values be used in parameter of setHorizonSpacing()?
>>
>> thanks in advance
>>
>> changwon
>>
>>
>> -- 
>> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx 
>> with "unsubscribe" in the subject or the body.
>> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
thank you for the answer

The reason why I adopted this method is that cells are not equal size. 
It is something like evaluation check sheet as following.

----------------------------------------------------
|                 header                |            header          |
----------------------------------------------------
|         |            |       |         |   
|                                |
----------------------------------------------------
|         |            |       |         |   
|                                |
----------------------------------------------------
|          header        |              |                                |
-----------------------------------------------------

I have no idea how to merge two or several cells in one in table widget 
and instead of setting location of each labels, I thought it would be 
better to use layout.

After insert lables into QGridLayout and setSpacing(0) for each label is 
drawn like this
----------------------------
|                 | |                     |
----------------------------
In this case two lines does not overlap, it looks like thicker line 
interior of table except boundary of layout.




--
 [ signature omitted ]