Home |
This example provides a simple application that hosts the MonthCalendar winforms control from a Qt application.
The .Net MonthCalendar running in a Qt application.
After initialization of QApplication, but before the instantiation of the QtControlHost the application must make sure that the QtWinForms is initialized properly by calling QtWinFormsUtils::initWindowsFormsForQt():
/****************************************************************************
**
** Copyright (C) 2003-2008 Trolltech ASA. All rights reserved.
**
** This file is part of a Qt Solutions component.
**
** Licensees holding a valid Qt Solutions License Agreement may use this
** file in accordance with the rights, responsibilities, and obligations
** contained therein. Please consult your licensing agreement or contact
** [email protected] if any conditions of this licensing are not clear
** to you.
**
** Further information about Qt Solutions licensing is available at:
** http://www.trolltech.com/products/qt/addon/solutions/
** or by contacting [email protected].
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/
#include <qtwinforms.h>
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QtWinFormsUtils::initWindowsFormsForQt();
MainWindow window;
window.show();
return app.exec();
}
Instantiation of the QtControlHost is done in the constructor of the MainWindow class:
MainWindow::MainWindow() { QVBoxLayout *vl = new QVBoxLayout(); calendar = gcnew System::Windows::Forms::MonthCalendar(); calendar->ShowToday = false; calendar->ShowTodayCircle = false; calendarHost = new QtControlHost(calendar, this); ... }
In this example we also modify some properties of the hosted control before we pass it in to the constructor of the QtControlHost.
Copyright © 2008 Nokia Corporation and/or its subsidiary(-ies) | Trademarks | Qt Solutions |