Kugadzira app yeUbuntu Kubata [QML] - [Chikamu 3]

Kugadzira Anwendung yeUbuntu Kubata

Chikamu chechitatu cheiyi posvo nhevedzano (chikamu chimwe, chikamu chechipiri) kwatiri kuvaka application kune Ubuntu Bata kana zvakafanana Ubuntu desktop. Ndiri kuzowedzera chikamu chakaitika kwandiri mune yapfuura posvo, uye izvo ndezvekuti kunyangwe isu takawedzera misiyano yekundikana, kurova uye mapoinzi, saka iwo haana kuratidzwa pachiratidziri, izvo nekuti hatina kuchinja chinyorwa chivakwa cheMazita:

                Label {id: failures text: "Failures:" + nfaults color: "red"} Label {id: hits text: "hits:" + born} Label {id: points text: "Points:" + npoints fontSize: "medium "}

Kuenderera kwemutambo wemafungiro

Nguva

Zvakanaka, sekuziva kwedu, kufambira mberiBar kunoratidza nguva yatinofanira kupindura mubvunzo. Kugadzirisa iyo nguva yatichashandisa iyo Timer, iyo timer chinhu chinhu chinodzokororwa pane chinguva che x milliseconds, mune ino nguva yega yega tichaiudza kuti iwedzere kufambira mberi kweProgressBar; Asi ndisati ndatarisa kana yasvika kumagumo enguva kana ikazosvika kumagumo, tinofanira kubvisa hupenyu.

Unogona kuona mutsara wekodhi isu tisati taita (PopupUtils.open (dialog)), uyu mutsetse ndeyekuvhura iyo endgame dialog kuitira kana tisisina hupenyu (3 bugs dzabviswa), gare gare mune ino posvo tichaona maitiro ekuita iyi nhaurirano.

Nguva kodhi (tinogona kuiisa pazasi peProgressBar):

       ProgressBar {id: nguva anchors.horizontalCenter: parent.horizontalCenter minimumValue: 0 maximumValue: 300} Timer {id: simpletimer c: 100 dzokorora: kumhanya kwechokwadi: kwechokwadi paTriggered: {if (time.value <time.maximumValue) time.value + = 1.0 zvimwe {nfaults = zvisipo + 1 kana (nfaults <3) {num = num + 1 Logic.nextQuestion (num) time.value = time.minimumValue} zvimwe {simpletimer.stop () PopupUtils.open (dialog)}} }}

Sekuona kwedu, mu onTriggered isu tinoisa kodhi iyo ichawedzera progressbar inowedzera 1 unit zana zana (chinguvamilli-masekondi. Ziva kuti isu takawedzera maviri maitiro ku ProgressBar, minimumValue uye maximumValue, iyo, sezvauri kuona, ndiyo yakanyanya kukosha uye iyo yakaderera kukosha.

Kutanga uye kumisa iyo timer:

simpleimer.start () simpletimer.stop ()

Sarudzo (50%, Gwamba uye Inotevera)

Kutanga ngatigadzirei matatu akasiyana anodzora kuti sarudzo dzinogona kushandiswa kamwe chete:

    chivakwa int muzana: 0 chivakwa int ne: 0 chivakwa int chinotevera: 0

50%

Bhatani {id: b50 zvinyorwa: "50%" zvadzvanywa: {if (percent == 0) {var correct = aDocument.contents.questions [num] .correcta if (correct == 1) {resp2.enabled = false resp3. enabled = nhema} zvimwe kana (chakarurama == 2) {resp1.enabled = nhema resp4.enabled = nhema} zvimwe kana (chakarurama == 3) {resp1.enabled = nhema resp4.enabled = nhema} zvimwe {resp2.enabled = nhema resp1.enabled = nhema} muzana = 1}}

Neyakagoneswa = manyepo zvatinoita kuisa bhatani kuti risakwanise kumanikidzwa, nenzira yekuti tiwane mhinduro chaiyo neDocument.contents.questions [num]. Yakarurama uye kubva pano zvichibva nekuti ndeipi chaiyo «isu bvisa »Mabhatani maviri asiri.

Fungidzira

                Bhatani {id: bCon chinyorwa: "Gwamba" paKadzvanywa: {kana (na == 0) simpletimer.stop () na = 1}}

Iyi ndeimwe yeayo akareruka, isu tinongofanirwa kumisa iyo timer ne simpletimer.stop (), ehe, isu tinofanirwa kuibatidza zvakare (uye nekuisa progressBar kusvika ku0) kana tichipfuura nemubvunzo.

Next

                 Bhatani {id: bNext chinyorwa: "Next" paClicked: {if (next == 0) {num = num + 1 Logic.nextQuestion (num) next = 1}}}

Isu tinoshandisa basa ratakatogadzira kupasa mubvunzo (nextQuestion).

Nhaurirano

Kupedza mutambo isu tinoshandisa Dialog, kungave nekuti takunda (hapachina mibvunzo) kana nekuti takarasa (takaita zvikanganiso zvitatu), kushandisa dialogs isu tinofanirwa kuendesa module:

pinza Ubuntu.Components.Popups 0.1

Tichagadzira dialog inotitaurira kuti tarasikirwa:

        Chikamu {id: dialog dialog {id: dialog title: "Game Over!" chinyorwa: "Wakarasikirwa nehupenyu hwese :(" Bhatani {zvinyorwa: "Regedza" paKadzvanywa: Qt.quit ()} Bhatani {mavara: "Start pamusoro" ruvara: UbuntuColors.orange onClicked: {num = 0; Logica.nextQuestion (num ) npoints = 0 kuzvarwa = 0 PopupUtils.vhara (hurukuro)}}}}

Tine mabhatani maviri, imwe yekuvhara iyo application (Qt.quit ()) uye imwe kutanga mutambo pamusoro. Isu tinotanga akasiyana kusvika ku0 uye tovhara dialog.

Kuvhura dialog:

PopupUtils.open (dialog)

Kuivhara:

PopupUtils.close (dialog)

Ngatione hurukuro panopera mutambo:

Ubuntu Bata

Tinogona kugadzira dialog yakafanana chaizvo nekushandura chinongedzo uye zvinyorwa panoti isu takunda.

Kugadzira iwo mubvunzo uwandu

Patinoigadzira mukati GTK, isu tinogadzira dialog, asi panguva ino tichazviita muTab, zvakadaro ichave iine chimiro chakafanana:

Sekuona kwedu, isu tinoshandisa Chitauro, ChinyorwaArea kunyora mubvunzo, 4 TextField uye 4 Chinja; pakupedzisira, Bhatani rekuwedzera mubvunzo. Ngatitarisei kodhi yacho:

kupinza QtQuick 2.0 kupinza Ubuntu.Components 0.1 Tab {zita: i18n.tr ("+ Mibvunzo") Peji {id: pageAdd Column {anchors.top: pageAdd.top anchors.topMargin: 50 spacing: 15 spacing: 50 width: parent.width height: parent.height - 20 Label {id: mubvunzo chinyorwa: "Wedzera mubvunzo kudhatabhesi:" anchors.horizontalCenter: parent.horizontalCenter fontSize: "hombe"} TextArea {upamhi: parent.width - 12 kukwirira: units.gu (30 ) contentWidth: units.gu (60) contentHeight: units.gu (15) anchors.horizontalCenter: parent.horizontalCenter} Row {spacing: 1 anchors.horizontalCenter: parent.horizontalCenter TextField {placeholderText: "Mhinduro 300" upamhi: 15} Chinja {checked: false}} Row {spacing: 2 anchors.horizontalCenter: parent.horizontalCenter TextField {placeholderText: "Response 300" upamhi: 15} Chinja {checked: false}} Row {spacing: 3 anchors.horizontalCenter: parent. horizontalCenter TextField {placeholderText: "Mhinduro 300" upamhi: 15} Chinja {checked: false}} Row {spacing: 4 anchors.horizontalCenter: parent.horizontalCenter TextField {placeholderText: "Mhinduro 300" upamhi: 20} Chinja {checked: false}} Bhatani {chinyorwa: "Wedzera +" zvimiso. HorizontalCenter: parent.horizontalCenter upamhi: parent.width - XNUMX}}}}
Kana paine kusahadzika pamusoro pekodhi iwe watoziva taura

Ngatione kuti inoratidzika sei:

Capture kubva 2014-07-24 16:54:37

Kana isu tave kuyedza maSwitch, tichaona kuti tinogona kumaka iwo ese semubvunzo wakakodzera, uye nenzira imwechete mumwe chete anogona kuva, saka tichaita zvinotevera: isu tinokwanisa kupa chinongedzo kuchinjiso yega yega (zvakare kune textfields sezvo isu tichafanirwa kutora izvo zvemukati kuti tizvichengetedze kune dhatabhesi) zvinoenderana nemhinduro yako, uye patinozvibaya tichaisa vamwe vese mu checked = false mode:

             Row {spacing: 15 anchors.horizontalCenter: parent.horizontalCenter TextField {id: res1 placeholderText: "Response 1" wide: 300} Chinja {id: sw1 checked: false onClicked: {if (sw1.checked == true) {sw2. checked = nhema sw3.checked = nhema sw4.checked = nhema}}}}

Kana tikazviedza izvozvi tichaona kuti tingamaka sei imwe chete.


Izvo zviri muchinyorwa zvinoomerera pamisimboti yedu ye tsika dzekunyora. Kuti utaure chikanganiso tinya pano.

Makomendi gumi, siya zvako

Siya yako yekutaura

Your kero e havazobvumirwi ichibudiswa.

*

*

  1. Inotarisira iyo data: Miguel Ángel Gatón
  2. Chinangwa cheiyo data: Kudzora SPAM, manejimendi manejimendi.
  3. Legitimation: Kubvuma kwako
  4. Kutaurirana kwedata
  5. Dhata yekuchengetedza: Dhatabhesi inobatwa neOccentus Networks (EU)
  6. Kodzero: Panguva ipi neipi iwe unogona kudzora, kupora uye kudzima ruzivo rwako

  1.   vr_rv akadaro

    Zvinyorwa zvakanaka kwazvo uye zvakatsanangurwa chaizvo.
    Nenzira, unokurudzira mamwe mabhuku, YouTube nzira kana maBlog ari muSpanish kuti udzidze kugadzira muQML yeUbuntu.

    1.    lolbimbo akadaro

      Zvakanaka, muchiSpanish pane chokwadi pane mamwe maYouTube, kana iro risinganzwisisike blog, asi chokwadi ndechekuti pane zvishoma zvinyorwa.

      Ndinoona kuti iwe unobatana kuburikidza nokia kana chiri chiratidzo chekupedzisira, unogona zvakare kugadzira mafomu neQML, zvirokwazvo ndiwo maitiro andakadzidza, heino nokia webhusaiti webhusaiti: http://developer.nokia.com/ (kune dzidziso, mapurojekiti akazara ...)

  2.   Nestor akadaro

    Yakanakisa post akateedzana, ndatenda nekuisa.

  3.   Marti akadaro

    Kutenda dzidziso,
    Asi ini handinzwisise kuti mibvunzo nemhinduro zvinowedzerwa sei mudhatabhesi.
    Nebhokisi rekuwedzera.
    Ndatenda zvese.

bool (chokwadi)