Safe Haskell | None |
---|---|
Language | Haskell2010 |
Functions for starting QML engines, displaying content in a window.
- data EngineConfig = EngineConfig {}
- defaultEngineConfig :: EngineConfig
- data Engine
- runEngine :: EngineConfig -> RunQML ()
- runEngineWith :: EngineConfig -> (Engine -> RunQML a) -> RunQML a
- runEngineAsync :: EngineConfig -> RunQML Engine
- runEngineLoop :: EngineConfig -> IO ()
- joinEngine :: Engine -> IO ()
- killEngine :: Engine -> IO ()
- data RunQML a
- runEventLoop :: RunQML a -> IO a
- runEventLoopNoArgs :: RunQML a -> IO a
- requireEventLoop :: RunQML a -> IO a
- setQtArgs :: String -> [String] -> IO Bool
- getQtArgs :: RunQML (String, [String])
- data QtFlag = QtShareOpenGLContexts
- setQtFlag :: QtFlag -> Bool -> IO Bool
- getQtFlag :: QtFlag -> RunQML Bool
- shutdownQt :: IO ()
- data EventLoopException
- data DocumentPath
- fileDocument :: FilePath -> DocumentPath
- uriDocument :: String -> DocumentPath
Engines
data EngineConfig Source #
Holds parameters for configuring a QML runtime engine.
EngineConfig | |
|
defaultEngineConfig :: EngineConfig Source #
Default engine configuration. Loads "main.qml"
from the current
working directory into a visible window with no context object.
runEngine :: EngineConfig -> RunQML () Source #
Starts a new QML engine using the supplied configuration and blocks until the engine has terminated.
runEngineWith :: EngineConfig -> (Engine -> RunQML a) -> RunQML a Source #
Starts a new QML engine using the supplied configuration. The 'with' function is executed once the engine has been started and after it returns this function blocks until the engine has terminated.
runEngineAsync :: EngineConfig -> RunQML Engine Source #
Starts a new QML engine using the supplied configuration and returns immediately without blocking.
runEngineLoop :: EngineConfig -> IO () Source #
Conveniance function that both runs the event loop and starts a new QML engine. It blocks keeping the event loop running until the engine has terminated.
joinEngine :: Engine -> IO () Source #
Waits for the specified Engine to terminate.
killEngine :: Engine -> IO () Source #
Kills the specified Engine asynchronously.
Event Loop
Wrapper around the IO monad for running actions which depend on the Qt event loop.
runEventLoop :: RunQML a -> IO a Source #
This function enters the Qt event loop and executes the supplied function
in the RunQML
monad on a new unbound thread. The event loop will continue
to run until all functions in the RunQML
monad have completed. This
includes both the RunQML
function launched by this call and any launched
asynchronously via requireEventLoop
. When the event loop exits, all
engines will be terminated.
It's recommended that applications run the event loop on their primordial
thread as some platforms mandate this. Once the event loop has finished, it
can be started again, but only on the same operating system thread as
before. If the event loop fails to start then an EventLoopException
will
be thrown.
If the event loop is entered for the first time then the currently set
runtime command line arguments will be passed to Qt. Hence, while calling
back to the supplied function, attempts to read the runtime command line
arguments using the System.Environment module will only return those
arguments not already consumed by Qt (per getQtArgs
).
runEventLoopNoArgs :: RunQML a -> IO a Source #
Enters the Qt event loop in the same manner as runEventLoop
, but does
not perform any processing related to command line arguments.
requireEventLoop :: RunQML a -> IO a Source #
Executes a function in the RunQML
monad asynchronously to the event
loop. Callers must apply their own sychronisation to ensure that the event
loop is currently running when this function is called, otherwise an
EventLoopException
will be thrown. The event loop will not exit until the
supplied function has completed.
setQtArgs :: String -> [String] -> IO Bool Source #
Sets the program name and command line arguments used by Qt and returns True if successful. This must be called before the first time the Qt event loop is entered otherwise it will have no effect and return False. By default Qt receives no arguments and the program name is set to HsQML.
getQtArgs :: RunQML (String, [String]) Source #
Gets the program name and any command line arguments remaining from an
earlier call to setQtArgs
once Qt has removed any it understands, leaving
only application specific arguments.
Represents a Qt application flag.
QtShareOpenGLContexts | Enables resource sharing between OpenGL contexts. This must be set in order to use QtWebEngine. |
setQtFlag :: QtFlag -> Bool -> IO Bool Source #
Sets or clears one of the application flags used by Qt and returns True if successful. If the flag or flag value is not supported then it will return False. Setting flags once the Qt event loop is entered is unsupported and will also cause this function to return False.
getQtFlag :: QtFlag -> RunQML Bool Source #
Gets the state of one of the application flags used by Qt.
shutdownQt :: IO () Source #
Shuts down and frees resources used by the Qt framework, preventing
further use of the event loop. The framework is initialised when
runEventLoop
is first called and remains initialised afterwards so that
the event loop can be reentered if desired (e.g. when using GHCi). Once
shut down, the framework cannot be reinitialised.
It is recommended that you call this function at the end of your program as this library will try, but cannot guarantee in all configurations to be able to shut it down for you. Failing to shutdown the framework has been known to intermittently cause crashes on process exit on some platforms.
This function must be called from the event loop thread and the event loop
must not be running at the time otherwise an EventLoopException
will be
thrown.
data EventLoopException Source #
Exception type used to report errors pertaining to the event loop.
Document Paths
data DocumentPath Source #
Path to a QML document file.
fileDocument :: FilePath -> DocumentPath Source #
Converts a local file path into a DocumentPath
.
uriDocument :: String -> DocumentPath Source #
Converts a URI string into a DocumentPath
.