1 / 13

Szebb és használhatóbb programok

Szebb és használhatóbb programok. Vezérlőelemek dinamikus felhelyezése. Statikus kezelőfelületek. Pro Könny ű létrehozni Gyorsan módosítható Nem kell számolgatni Kontra Nem alkalmazkodik a változásokhoz Több ablakra ( form ra) van szükség A szerkesztéséhez keretprogram kell.

eve
Télécharger la présentation

Szebb és használhatóbb programok

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Szebb és használhatóbb programok Vezérlőelemek dinamikus felhelyezése

  2. Statikus kezelőfelületek • Pro • Könnyű létrehozni • Gyorsan módosítható • Nem kell számolgatni • Kontra • Nem alkalmazkodik a változásokhoz • Több ablakra (formra) van szükség • A szerkesztéséhez keretprogram kell

  3. Dinamikus kezelőfelületek • Pro • Az igényeknek megfelelő elrendezés • Elég egy form • Módszertanilag elegánsabb megvalósítás • Kontra • Nehezebb létrehozni • Több időbe kerül (újra) átlátni • Esetenként sok számolást igényel

  4. Microsoft .NET • Visual Studio • .Designer.cs és .cs fájl (mert a help használata nehézkes) • Mintaelem létrehozása, attribútumokbeállítása (designer) • Kezelés ellesése (.Designer.cs)

  5. Trolltech QT • Designer • .ui és .ui.h fájl (mert az assistant sem jobb) • Mintaelem fölrakása, tulajdonságok,kapcsolatok beállítása (designer) • .ui → .h és .cpp (uic)

  6. .ui fájl • XML formátum • Elődeklaráció: <forward> • Változó: <variable> • Tagfüggvény: <function> • Slot: <slot> • Attribútumok: • Hozzáférés: access (protected, private) • Visszatérés típusa: returnType

  7. .NET Button b =new Button(); this.Controls.Add(b); b.Name =”PushMe”; b.Location = Location(10, 10); b.Size =new Size(96, 32); b.Text =”Push me!”; b.Click +=new System.EventHandler(pushed); b.Show(); QT QPushButton b =new QPushButton(this, ”PushMe”); b->setGeometry(QRect(10, 10, 96, 32)); b->setText(”Push me!”); connect(b, SIGNAL(clicked()),this, SLOT(pushed())); b->show(); Hasonlóságok, eltérések #1 Elhagyható Fontos!

  8. .NET void pushed(object sender, EventArgs e) { Button b = (Button) sender; string name = b.Name; b.BackColor = Color.Green; . . . } QT void pushed() { QPushButton b = (QPushButton) sender(); QString name = b->name(); b->setPaletteBackgroundColor (QColor(0, 0, 255)); . . . } Hasonlóságok, eltérések #2

  9. Gombsor létrehozása (.NET) #1 private Button[] btn; ... void update(int size) { // removing controls... foreach(Button b in btn) this.Container.Remove(b); // we don’t need to ‘delete’ anything, // the garbage collector will clean up the mess . . .

  10. Gombsor létrehozása (.NET) #2 . . . // creating controls... btn =new Button[size]; for(int i =0; i < size; ++i){ btn[i] = new Button(); btn[i].Location =new Location(10 + 32 * size, 10); btn[i].Size =new Size(32, 32); btn[i].Text = i.ToString(); this.Container.Add(btn[i]); } }

  11. Gombsor létrehozása (QT) #1 private QPushButton** btn; ... void update(int size) { // this widget takes control // of the replaced buttons QWidget w(); for(int i =0; i < size; ++i) btn[i]->reparent(&w, QPoint(0, 0)); // destroy container delete[] btn; . . .

  12. Gombsor létrehozása (QT) #2 . . . // create container btn =new button[size]; // and the new row... for(int i =0; i < size; ++i) { btn[i]=new QPushButton(this); btn[i]->setGeometry(QRect(10+32* size, 10, 32, 32)); btn[i]->setText(QString().setNum(i)); btn[i]->show(); } }

  13. Microsoft .NET Trolltech QT Példa: moziterem

More Related