Sie sind auf Seite 1von 10

Ring Documentation, Release 1.

Table 56.1 continued from previous page


Class Name Methods to use the default Events
SetSelectionChangedEvent()
SetTextChangedEvent()
SetUndoAvailableEvent()
QListWidget SetCurrentItemChangedEvent()
SetCurrentRowChangedEvent()
SetCurrentTextChangedEvent()
SetItemActivatedEvent()
SetItemChangedEvent()
SetItemClickedEvent()
SetItemDoubleClickedEvent()
SetItemEnteredEvent()
SetItemPressedEvent()
SetItemSelectionChangedEvent()
QTreeView SetCollapseEvent()
SetExpandedEvent()
SetActivatedEvent()
SetClickedEvent()
SetDoubleClickedEvent()
SetEnteredEvent()
SetPressedEvent()
SetViewportEnteredEvent()
QTreeWidget SetCollapsedEvent()
SetExpandedEvent()
SetActivatedEvent()
SetClickedEvent()
SetDoubleClickedEvent()
SetEnteredEvent()
SetPressedEvent()
SetViewportEnteredEvent()
SetCurrentItemChangedEvent()
SetItemActivatedEvent()
SetItemChangedEvent()
SetItemClickedEvent()
SetItemCollapsedEvent()
SetItemDoubleClickedEvent()
SetItemEnteredEvent()
SetItemExpandedEvent()
SetItemPressedEvent()
SetItemSelectionChangedEvent()
QComboBox SetActivatedEvent()
SetCurrentIndexChangedEvent()
SetEditTextChangedEvent()
SetHighlightedEvent()
QTabWidget SetCurrentChangedEvent()
SetTabCloseRequestedEvent()
QTableWidget SetCellActivatedEvent()
SetCellChangedEvent()
SetCellClickedEvent()
SetCellDoubleClickedEvent()
Continued on next page

56.55. Classes and their Methods to use the default events 625
Ring Documentation, Release 1.5

Table 56.1 continued from previous page


Class Name Methods to use the default Events
SetCellEnteredEvent()
SetCellPressedEvent()
SetCurrentCellChangedEvent()
SetCurrentItemChangedEvent()
SetItemActivatedEvent()
SetItemChangedEvent()
SetItemClickedEvent()
SetItemDoubleClickedEvent()
SetItemEnteredEvent()
SetItemPressedEvent()
SetItemSelectionChangedEvent()
QProgressBar SetValueChangedEvent()
QSpinBox SetValueChangedEvent()
QSlider SetActionTriggeredEvent()
SetRangeChangedEvent()
SetSliderMovedEvent()
SetSliderPressedEvent()
SetSliderReleasedEvent()
SetValueChangedEvent()
QDial SetActionTriggeredEvent()
SetRangeChangedEvent()
SetSliderMovedEvent()
SetSliderPressedEvent()
SetSliderReleasedEvent()
SetValueChangedEvent()
QWebView SetLoadFinishedEvent()
SetLoadProgressEvent()
SetLoadStartedEvent()
SetSelectionChangedEvent()
SetTitleChangedEvent()
SetUrlChangedEvent()
QCheckBox SetStateChangedEvent()
SetClickedEvent()
SetPressedEvent()
SetReleasedEvent()
SetToggledEvent()
QRadioButton SetClickedEvent()
SetPressedEvent()
SetReleasedEvent()
SetToggledEvent()
QButtonGroup SetButtonClickedEvent()
SetButtonPressedEvent()
SetButtonReleasedEvent()
QVideoWidget SetBrightnessChangedEvent()
SetContrastChangedEvent()
SetFullScreenChangedEvent()
SetHueChangedEvent()
SetSaturationChangedEvent()
QTimer SetTimeoutEvent()
Continued on next page

56.55. Classes and their Methods to use the default events 626
Ring Documentation, Release 1.5

Table 56.1 continued from previous page


Class Name Methods to use the default Events
QTcpServer SetAcceptErrorEvent()
SetNewConnectionEvent()
QIODevice SetAboutToCloseEvent()
SetBytesWrittenEvent()
SetReadChannelFinishedEvent()
SetReadyReadEvent()
QAbstractSocket SetConnectedEvent()
SetDisconnectedEvent()
SetErrorEvent()
SetHostFoundEvent()
SetProxyAuthenticationRequiredEvent()
SetStateChangedEvent()
QTcpSocket SetConnectedEvent()
SetDisconnectedEvent()
SetErrorEvent()
SetHostFoundEvent()
SetProxyAuthenticationRequiredEvent()
SetStateChangedEvent()
SetAboutToCloseEvent()
SetBytesWrittenEvent()
SetReadChannelFinishedEvent()
SetReadyReadEvent()
QColorDialog SetColorSelectedEvent()
SetCurrentColorChangedEvent()
QNetworkAccessManager SetFinishedEvent()
QThread SetStartedEvent()
SetFinishedEvent()

56.56 Methods to use Events with Events Filter

RingQt define a new class called QAllEvents that help you in using Events Filter
The next table presents the methods that we have
Methods to get parameters Class Name
getKeyCode() > Number QAllEvents
getx() > Number
gety() > Number
getglobalx() > Number
getglobaly() > Number
getbutton() > Number
getbuttons() > Number
The next table presents the methods that we have to use events.

56.56. Methods to use Events with Events Filter 627


Ring Documentation, Release 1.5

Method Name Class Name


setKeyPressEvent(cEvent) QAllEvents
setMouseButtonPressEvent(cEvent)
setMouseButtonReleaseEvent(cEvent)
setMouseButtonDblClickEvent(cEvent)
setMouseMoveEvent(cEvent)
setCloseEvent(cEvent)
setContextMenuEvent(cEvent)
setDragEnterEvent(cEvent)
setDragLeaveEvent(cEvent)
setDragMoveEvent(cEvent)
setDropEvent(cEvent)
setEnterEvent(cEvent)
setFocusInEvent(cEvent)
setFocusOutEvent(cEvent)
setKeyReleaseEvent(cEvent)
setLeaveEvent(cEvent)
setNonClientAreaMouseButtonDblClickEvent(cEvent)
setNonClientAreaMouseButtonPressEvent(cEvent)
setNonClientAreaMouseButtonReleaseEvent(cEvent)
setNonClientAreaMouseMoveEvent(cEvent)
setMoveEvent(cEvent)
setResizeEvent(cEvent)
setWindowActivateEvent(cEvent)
setWindowBlockedEvent(cEvent)
setWindowDeactivateEvent(cEvent)
setWindowStateChangeEvent(cEvent)
setWindowUnblockedEvent(cEvent)

56.57 The Difference between Qt and RingQt

1. RingQt use simple methods to set the code that will be executed for events.
Syntax:
Set<Event_Name>Event(cEventCode)

2. RingQt change the name of some methods to avoid conflict with Ring Keywords.
The next table present these little changes

56.57. The Difference between Qt and RingQt 628


Ring Documentation, Release 1.5

Class Name Qt Method Name RingQt Method Name


QWebView load loadpage
QMediaPlaylist load loadfile
QMediaPlaylist next movenext
QPainter end endpaint
QPicture load loadfile
QLineEdit end endtext
QDialog done donedialog
QTextDocument end enddoc
QTextBlock next nextblock
QSqlQuery next movenext
QImage load loadimage
QNetworkAccessManager get getvalue
QNetworkAccessManager put putvalue
QThread exit exitfromthread
QRegularExpressionMatchIterator next nextitem
QCamera load loadcamera

56.58 RingQt Classes and their Qt Documentation

Qt Documentation : http://doc.qt.io/qt-5/classes.html
See the RingQt Classes and Methods Reference chapter for supported classes and methods.

56.59 New Classes names - Index Start from 1

We added new classes to RingQt - another version of classes where the class names doesnt start with the q letter
Also updated methods so the index start from 1 when we deal with the GUI controls like
ComboBox
ListWidget
TableWidget
TreeWidget
These classes are inside guilib.ring under the package name : System.GUI
To use it
load "guilib.ring"

import System.GUI

This doesnt have any effect on our previous code, Its just another choice for better code that is consistent with Ring
rules.
Also the form designer is updated to provide us the choice between using classes where (index start from 0) or (index
start from 1)
Example (Uses the Form Designer)
1. https://github.com/ring-lang/ring/blob/master/applications/formdesigner/tests/indexstart/indexstartView.ring
2. https://github.com/ring-lang/ring/blob/master/applications/formdesigner/tests/indexstart/indexstartController.ring

56.58. RingQt Classes and their Qt Documentation 629


Ring Documentation, Release 1.5

56.60 Creating Reports using the WebLib and the GUILib

The WebLib comes with a class called HtmlPage


Using this class we can create reports quickly using WebLib & GUILib together
Example:
load "stdlib.ring"
load "weblib.ring"
load "guilib.ring"

import System.Web
import System.GUI

new qApp {
open_window(:CustomersReportController)
exec()
}

class CustomersReportController

oView = new CustomersReportView

func Start
CreateReport()

func CreateReport
mypage = new HtmlPage {
h1 { text("Customers Report") }
Table
{
style = stylewidth("100%") + stylegradient(4)
TR
{
TD { WIDTH="10%"
text("Customers Count : " ) }
TD { text (100) }
}
}
Table
{
style = stylewidth("100%") + stylegradient(26)
TR
{
style = stylewidth("100%") +
stylegradient(24)
TD { text("Name " ) }
TD { text("Age" ) }
TD { text("Country" ) }
TD { text("Job" ) }
TD { text("Company" ) }
}
for x = 1 to 100
TR
{
TD { text("Test" ) }
TD { text("30" ) }
TD { text("Egypt" ) }

56.60. Creating Reports using the WebLib and the GUILib 630
Ring Documentation, Release 1.5

TD { text("Sales" ) }
TD { text("Future" ) }
}
next
}
}
write("report.html",mypage.output())

func PrintEvent
printer1 = new qPrinter(0) {
setoutputformat(1)
setoutputfilename("report.pdf")
}
oView {
web.print(printer1)
web.show()
}
system ("report.pdf")

class CustomersReportView

win = new window() {


setwindowtitle("Report Window")
setgeometry(100,100,500,500)
web = new webview(win) {
setgeometry(100,100,1000,500)
loadpage(new qurl("file:///"+
currentdir()+"/report.html"))
}
new pushbutton(win) {
setGeometry(100,20,100,30)
settext("Print")
setclickevent(Method(:PrintEvent))
}
showMaximized()
}

Screen Shot:

56.60. Creating Reports using the WebLib and the GUILib 631
Ring Documentation, Release 1.5

56.60. Creating Reports using the WebLib and the GUILib 632
CHAPTER

FIFTYSEVEN

BUILDING RINGQT APPLICATIONS FOR MOBILE

In this chapter we will learn about Building RingQt Applications for Mobile.

57.1 Download Requirements

Check the next link : http://doc.qt.io/qt-5/androidgs.html


Download
The Android SDK Tools
https://developer.android.com/studio/index.html
The Android NDK
https://developer.android.com/ndk/index.html
Apache Ant v1.8 or later
http://ant.apache.org/bindownload.cgi
Java SE Development Kit (JDK) v6 or later
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

57.2 Update the Android SDK

Update the Android SDK to get the API and tools packages required for development

57.3 Install Qt for Android

You can install Qt for Android from the next link


https://download.qt.io/archive/qt/5.5/5.5.1/
Run Qt Creator, Select Tools > Options > Android to add the Android NDK and SDK paths.
http://doc.qt.io/qtcreator/creator-developing-android.html
Using Qt Creator Open the project
Folder : ring/android/ringqt/project
Project file : project.pro

633
Ring Documentation, Release 1.5

You will find the code in resourcestest.ring


You can modify the code then build and run for Desktop or Mobile.

57.4 Comments about developing for Android using RingQt

1. The main project file is main.cpp


This file load Ring Compiler/Virtual Machine and RingQt
Then copy files during the runtime from the resources to temp. folder
Then run the test.ring
Through main.cpp you can extract more files from the resources to temp. folder once you add them
(create projects with many files).
2. The next functions are missing from this Ring edition
Database (ODBC, SQLite & MySQL)
Security and Internet functions (LibCurl & OpenSSL)
RingAllegro (Allegro Library)
RingLibSDL (LibSDL Library)
Just use Qt Classes through RingQt.
For database access use the QSqlDatabase Class

Note: All of the missing libraries ((LibCurl, OpenSSL & Allegro) can be compiled for Android, but they are not
included in this Qt project.

3. use if isandroid() when you want to modify the code just for android

57.4. Comments about developing for Android using RingQt 634

Das könnte Ihnen auch gefallen