Page 3 of 15

Re: hbQT - Post queries in this thread only

Posted: Sun Sep 05, 2010 1:30 am
by Roberto Lopez
bedipritpal wrote:
Roberto Lopez wrote: There is no special code. It is simply demoqt with Harbour built from current (a couple of days ago) sources.
The same works perfect on Windows.
Try:

oActNew := QAction():new( oMenu1 )
oActNew:setText( "&New" )
oActNew:setIcon( "new.png" )
oActNew:connect( "triggered(bool)", {|w,l| FileDialog( "New" , w, l ) } )
oMenu1:addAction_4( oActNew )
The problem remains the same. The image is not shown.

Re: hbQT - Post queries in this thread only

Posted: Sun Sep 05, 2010 1:34 am
by bedipritpal
A little suggestion:

Since QT official reference samples (and most of those we can find on the web) are C++ based, could be very useful if you could write a small HOWTO file, explaining how to handle certain situations when the translation of the code is not obvious for a Harbour/xBase programmer without C++ knowledge.
This aspect has gained more importance now as you have decided to base HMG on hbQT.
I do not commit but I will try to write one. In all practical situations you can easily grasp the
idea off hbIDE sources which exploits almost all classes of Qt.

As a rule of hbQT implementation, a pointer has to be encapsulated within return type object,
which on the issue we just resolved is - qPainter:device(). If you read Qt's documentation
QPainter():device() returns the QPaintDevice() *. Just encapsulate it in QPaintDevice():from( painter:device() ).
This holds good for all other classes too.

BTW I just downloaded HMG sources and the first scan have a suggestion for you:
The code is haphazardly formatted, indentation is TAB key but anybody touching the code
takes his/her own path, and many more anomalies. The code is entirely off Harbour standards on formatting levels.

I agree that writing the correct and efficient code is of utmost importance, but it is equally important
to have it presentable. I could not ascertain the correct picture of HMG object modal at all and after
few minutes gave up.

You can suggest your developers to use hbIDE. That could be an important resource for your team
to learn how Qt can be exploited best besides provoding necessary tips on formatting front.

This is simply a suggestion, you may follow or descard, entirely upto you.

Re: hbQT - Post queries in this thread only

Posted: Sun Sep 05, 2010 1:40 am
by bedipritpal
The problem remains the same. The image is not shown.
I have no idea then.

Re: hbQT - Post queries in this thread only

Posted: Sun Sep 05, 2010 1:54 am
by Roberto Lopez
bedipritpal wrote:This aspect has gained more importance now as you have decided to base HMG on hbQT.
<...>
Thanks for your explanations and suggestions.

Of course, I strongly agree with you in the formatting issue. It must be solved.

Re: hbQT - Post queries in this thread only

Posted: Mon Sep 06, 2010 4:49 pm
by Rathinagiri
Thanks a lot for your detailed review Bedi.

I usually don't use tab key and give 3 spaces indentation. I will try HBIDE. Thanks for suggesting.

Re: hbQT - Post queries in this thread only

Posted: Mon Sep 06, 2010 9:01 pm
by mol
I'm repeatting my post here:
Hi Pritpal!
First - Welcome from Poland!
Second - I have a question about QComboBox.
I need to realize SORT option - when all inserted items are sorted.
I've read about Insert Policies, but, in my opinion, they don't work.
Do you have any suggestion about it?

Code: Select all

			if lValue == .T.
				::oQTObject:setInsertPolicy(6)   //QComboBox::InsertAlphabetically
			else
				::oQTObject:setInsertPolicy(3) //QComboBox::InsertAtBottom
			endif

Re: hbQT - Post queries in this thread only

Posted: Mon Sep 06, 2010 9:43 pm
by bedipritpal
mol wrote: I need to realize SORT option - when all inserted items are sorted.
I've read about Insert Policies, but, in my opinion, they don't work.
This is Qt documentation :

enum QComboBox::InsertPolicy
This enum specifies what the QComboBox should do when a new string is entered by the user.
^^^^^^^^^^^^^^^^

So this enum is used when user enters string the the combo-box's edit control.
:addItem()/:insertItem() always takes the bottom, or index of the item.

To simulate thi behavior, you need to keep array of strings into a instance vriable.
clear the combobox contents first and then push the sordted array you just preserved.
Like this :

DATA aComboItems INIT {}
METHOD addItem( cItem ) SETGET

METHOD ClassComboBox:addItem( cItem )
LOCAL s

IF hb_isChar( cItem )
aadd( ::aComboItems, cItem )
asort( ::aComboItems, , , {|e,f| e < f } )
::oQtObject:clear()
FOR EACH s IN ::aComboItems
::oQtObject:addItem( s )
NEXT
ENDIF
RETURN Self

You can tweak the above code to suit your requirements.
Unluckily QComboBox() does not have any sorting methods, we are to simulate ourselves.

Re: hbQT - Post queries in this thread only

Posted: Tue Sep 07, 2010 5:15 am
by mol
Thanks!
I've expected Qcombobox will sort items :)
Now, I can see, it need to be realized manually.

Re: hbQT - Post queries in this thread only

Posted: Tue Sep 07, 2010 6:09 am
by Rathinagiri
Hi,

Should I do anything else to make this work? I want to add an action enabled label when the user clicks on it. This is to add this widget to the status bar. I tried QPushButton instead. But it looks differently (center aligned, raised) when compared to other non-action oriented status bar items.

Code: Select all

   oWidget := QLabel():New()
   oWidget:setText('Clickable Label')
   oWidget:setMouseTracking(.t.)
   oWidget:disconnect("mouseReleaseEvent()")
   oWidget:connect("mouseReleaseEvent()",bBlock)

Re: hbQT - Post queries in this thread only

Posted: Tue Sep 07, 2010 7:12 am
by bedipritpal
rathinagiri wrote:Hi,

Should I do anything else to make this work? I want to add an action enabled label when the user clicks on it. This is to add this widget to the status bar. I tried QPushButton instead. But it looks differently (center aligned, raised) when compared to other non-action oriented status bar items.

Code: Select all

   oWidget := QLabel():New()
   oWidget:setText('Clickable Label')
   oWidget:setMouseTracking(.t.)
   oWidget:disconnect("mouseReleaseEvent()")
   oWidget:connect("mouseReleaseEvent()",bBlock)
oWidget := QLabel():New()
oWidget:setText( "<a href='http://harbour-project.org/'>http://har ... ct.org/</a>" )
oWidget:connect( "linkActivated(QString)", {|QString| ::execEvent( QString ) } )