Removed useless files from docs.
This commit is contained in:
parent
eedc03ebb5
commit
97a16f10ab
54 changed files with 0 additions and 1743 deletions
|
|
@ -1,18 +0,0 @@
|
||||||
//! [0]
|
|
||||||
function setNumber(number)
|
|
||||||
{
|
|
||||||
n = number;
|
|
||||||
}
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
QValueList args;
|
|
||||||
args << 5;
|
|
||||||
script->call("setNumber(const QVariant&)", args);
|
|
||||||
//! [1]
|
|
||||||
|
|
||||||
|
|
||||||
//! [2]
|
|
||||||
script->call("setNumber(5)");
|
|
||||||
//! [2]
|
|
||||||
|
|
@ -1,60 +0,0 @@
|
||||||
//! [0]
|
|
||||||
class MyActiveX : public QWidget, public QAxBindable
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(int value READ value WRITE setValue)
|
|
||||||
|
|
||||||
public:
|
|
||||||
MyActiveX(QWidget *parent = 0);
|
|
||||||
...
|
|
||||||
|
|
||||||
int value() const;
|
|
||||||
void setValue(int);
|
|
||||||
};
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
void MyActiveQt::setText(const QString &text)
|
|
||||||
{
|
|
||||||
if (!requestPropertyChange("text"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// update property
|
|
||||||
|
|
||||||
propertyChanged("text");
|
|
||||||
}
|
|
||||||
//! [1]
|
|
||||||
|
|
||||||
|
|
||||||
//! [2]
|
|
||||||
long AxImpl::queryInterface(const QUuid &iid, void **iface)
|
|
||||||
{
|
|
||||||
*iface = 0;
|
|
||||||
if (iid == IID_ISomeCOMInterface)
|
|
||||||
*iface = (ISomeCOMInterface*)this;
|
|
||||||
else
|
|
||||||
return E_NOINTERFACE;
|
|
||||||
|
|
||||||
AddRef();
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
//! [2]
|
|
||||||
|
|
||||||
|
|
||||||
//! [3]
|
|
||||||
HRESULT AxImpl::QueryInterface(REFIID iid, void **iface)
|
|
||||||
{
|
|
||||||
return controllingUnknown()->QueryInterface(iid, iface);
|
|
||||||
}
|
|
||||||
|
|
||||||
ulong AxImpl::AddRef()
|
|
||||||
{
|
|
||||||
return controllingUnknown()->AddRef();
|
|
||||||
}
|
|
||||||
|
|
||||||
ulong AxImpl::Release()
|
|
||||||
{
|
|
||||||
return controllingUnknown()->Release();
|
|
||||||
}
|
|
||||||
//! [3]
|
|
||||||
|
|
@ -1,155 +0,0 @@
|
||||||
//! [0]
|
|
||||||
QStringList ActiveQtFactory::featureList() const
|
|
||||||
{
|
|
||||||
QStringList list;
|
|
||||||
list << "ActiveX1";
|
|
||||||
list << "ActiveX2";
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
QObject *ActiveQtFactory::createObject(const QString &key)
|
|
||||||
{
|
|
||||||
if (key == "ActiveX1")
|
|
||||||
return new ActiveX1(parent);
|
|
||||||
if (key == "ActiveX2")
|
|
||||||
return new ActiveX2(parent);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QMetaObject *ActiveQtFactory::metaObject(const QString &key) const
|
|
||||||
{
|
|
||||||
if (key == "ActiveX1")
|
|
||||||
return &ActiveX1::staticMetaObject;
|
|
||||||
if (key == "ActiveX2")
|
|
||||||
return &ActiveX2::staticMetaObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
QUuid ActiveQtFactory::classID(const QString &key) const
|
|
||||||
{
|
|
||||||
if (key == "ActiveX1")
|
|
||||||
return "{01234567-89AB-CDEF-0123-456789ABCDEF}";
|
|
||||||
...
|
|
||||||
return QUuid();
|
|
||||||
}
|
|
||||||
|
|
||||||
QUuid ActiveQtFactory::interfaceID(const QString &key) const
|
|
||||||
{
|
|
||||||
if (key == "ActiveX1")
|
|
||||||
return "{01234567-89AB-CDEF-0123-456789ABCDEF}";
|
|
||||||
...
|
|
||||||
return QUuid();
|
|
||||||
}
|
|
||||||
|
|
||||||
QUuid ActiveQtFactory::eventsID(const QString &key) const
|
|
||||||
{
|
|
||||||
if (key == "ActiveX1")
|
|
||||||
return "{01234567-89AB-CDEF-0123-456789ABCDEF}";
|
|
||||||
...
|
|
||||||
return QUuid();
|
|
||||||
}
|
|
||||||
|
|
||||||
QAXFACTORY_EXPORT(
|
|
||||||
ActiveQtFactory, // factory class
|
|
||||||
"{01234567-89AB-CDEF-0123-456789ABCDEF}", // type library ID
|
|
||||||
"{01234567-89AB-CDEF-0123-456789ABCDEF}" // application ID
|
|
||||||
)
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
QAXFACTORY_BEGIN(
|
|
||||||
"{01234567-89AB-CDEF-0123-456789ABCDEF}", // type library ID
|
|
||||||
"{01234567-89AB-CDEF-0123-456789ABCDEF}" // application ID
|
|
||||||
)
|
|
||||||
QAXCLASS(Class1)
|
|
||||||
QAXCLASS(Class2)
|
|
||||||
QAXFACTORY_END()
|
|
||||||
//! [1]
|
|
||||||
|
|
||||||
|
|
||||||
//! [2]
|
|
||||||
#include <qapplication.h>
|
|
||||||
#include <qaxfactory.h>
|
|
||||||
|
|
||||||
#include "theactivex.h"
|
|
||||||
|
|
||||||
QAXFACTORY_DEFAULT(
|
|
||||||
TheActiveX, // widget class
|
|
||||||
"{01234567-89AB-CDEF-0123-456789ABCDEF}", // class ID
|
|
||||||
"{01234567-89AB-CDEF-0123-456789ABCDEF}", // interface ID
|
|
||||||
"{01234567-89AB-CDEF-0123-456789ABCDEF}", // event interface ID
|
|
||||||
"{01234567-89AB-CDEF-0123-456789ABCDEF}", // type library ID
|
|
||||||
"{01234567-89AB-CDEF-0123-456789ABCDEF}" // application ID
|
|
||||||
)
|
|
||||||
//! [2]
|
|
||||||
|
|
||||||
|
|
||||||
//! [3]
|
|
||||||
settings->setValue("/CLSID/" + classID(key)
|
|
||||||
+ "/Implemented Categories/"
|
|
||||||
+ "/{00000000-0000-0000-000000000000}/.",
|
|
||||||
QString());
|
|
||||||
//! [3]
|
|
||||||
|
|
||||||
|
|
||||||
//! [4]
|
|
||||||
settings->remove("/CLSID/" + classID(key)
|
|
||||||
+ "/Implemented Categories"
|
|
||||||
+ "/{00000000-0000-0000-000000000000}/.");
|
|
||||||
//! [4]
|
|
||||||
|
|
||||||
|
|
||||||
//! [5]
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
QApplication app(argc, argv);
|
|
||||||
if (!QAxFactory::isServer()) {
|
|
||||||
// initialize for stand-alone execution
|
|
||||||
}
|
|
||||||
return app.exec();
|
|
||||||
}
|
|
||||||
//! [5]
|
|
||||||
|
|
||||||
|
|
||||||
//! [6]
|
|
||||||
if (QAxFactory::isServer()) {
|
|
||||||
QAxFactory::stopServer();
|
|
||||||
QAxFactory::startServer(QAxFactory::SingleInstance);
|
|
||||||
}
|
|
||||||
//! [6]
|
|
||||||
|
|
||||||
|
|
||||||
//! [7]
|
|
||||||
#include <qaxfactory.h>
|
|
||||||
|
|
||||||
#include "theactivex.h"
|
|
||||||
|
|
||||||
QAXFACTORY_DEFAULT(
|
|
||||||
TheActiveX, // widget class
|
|
||||||
"{01234567-89AB-CDEF-0123-456789ABCDEF}", // class ID
|
|
||||||
"{01234567-89AB-CDEF-0123-456789ABCDEF}", // interface ID
|
|
||||||
"{01234567-89AB-CDEF-0123-456789ABCDEF}", // event interface ID
|
|
||||||
"{01234567-89AB-CDEF-0123-456789ABCDEF}", // type library ID
|
|
||||||
"{01234567-89AB-CDEF-0123-456789ABCDEF}" // application ID
|
|
||||||
)
|
|
||||||
//! [7]
|
|
||||||
|
|
||||||
|
|
||||||
//! [8]
|
|
||||||
QAXFACTORY_EXPORT(
|
|
||||||
MyFactory, // factory class
|
|
||||||
"{01234567-89AB-CDEF-0123-456789ABCDEF}", // type library ID
|
|
||||||
"{01234567-89AB-CDEF-0123-456789ABCDEF}" // application ID
|
|
||||||
)
|
|
||||||
//! [8]
|
|
||||||
|
|
||||||
|
|
||||||
//! [9]
|
|
||||||
QAXFACTORY_BEGIN(
|
|
||||||
"{01234567-89AB-CDEF-0123-456789ABCDEF}", // type library ID
|
|
||||||
"{01234567-89AB-CDEF-0123-456789ABCDEF}" // application ID
|
|
||||||
)
|
|
||||||
QAXCLASS(Class1)
|
|
||||||
QAXCLASS(Class2)
|
|
||||||
QAXFACTORY_END()
|
|
||||||
//! [9]
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
//! [0]
|
|
||||||
QString value = retrieveValue();
|
|
||||||
QDBusMessage reply;
|
|
||||||
|
|
||||||
QDBusReply<int> api = interface->call(QLatin1String("GetAPIVersion"));
|
|
||||||
if (api >= 14)
|
|
||||||
reply = interface->call(QLatin1String("ProcessWorkUnicode"), value);
|
|
||||||
else
|
|
||||||
reply = interface->call(QLatin1String("ProcessWork"), QLatin1String("UTF-8"), value.toUtf8());
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
QString value = retrieveValue();
|
|
||||||
QDBusPendingCall pcall = interface->asyncCall(QLatin1String("Process"), value);
|
|
||||||
|
|
||||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall, this);
|
|
||||||
|
|
||||||
QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
|
|
||||||
this, SLOT(callFinishedSlot(QDBusPendingCallWatcher*)));
|
|
||||||
//! [1]
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
//! [0]
|
|
||||||
class MyObject: public QObject,
|
|
||||||
protected QDBusContext
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
QDBusConnection conn;
|
|
||||||
QDBusMessage msg;
|
|
||||||
|
|
||||||
...
|
|
||||||
|
|
||||||
protected slots:
|
|
||||||
void process();
|
|
||||||
public slots:
|
|
||||||
void methodWithError();
|
|
||||||
QString methodWithDelayedReply();
|
|
||||||
};
|
|
||||||
|
|
||||||
void MyObject::methodWithError()
|
|
||||||
{
|
|
||||||
sendErrorReply(QDBusError::NotSupported,
|
|
||||||
"The method call 'methodWithError()' is not supported");
|
|
||||||
}
|
|
||||||
|
|
||||||
QString MyObject::methodWithDelayedReply()
|
|
||||||
{
|
|
||||||
conn = connection();
|
|
||||||
msg = message();
|
|
||||||
setDelayedReply(true);
|
|
||||||
QMetaObject::invokeMethod(this, "process", Qt::QueuedConnection);
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
//! [0]
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
//! [0]
|
|
||||||
QDBusInterface remoteApp( "com.example.Calculator", "/Calculator/Operations",
|
|
||||||
"org.mathematics.RPNCalculator" );
|
|
||||||
remoteApp.call( "PushOperand", 2 );
|
|
||||||
remoteApp.call( "PushOperand", 2 );
|
|
||||||
remoteApp.call( "ExecuteOperation", "+" );
|
|
||||||
QDBusReply<int> reply = remoteApp.call( "PopOperand" );
|
|
||||||
|
|
||||||
if ( reply.isValid() )
|
|
||||||
printf( "%d", reply.value() ); // prints 4
|
|
||||||
//! [0]
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
//! [0]
|
|
||||||
qDBusRegisterMetaType<MyClass>();
|
|
||||||
//! [0]
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
//! [0]
|
|
||||||
QDBusReply<QString> reply = interface->call("RemoteMethod");
|
|
||||||
if (reply.isValid())
|
|
||||||
// use the returned value
|
|
||||||
useValue(reply.value());
|
|
||||||
else
|
|
||||||
// call failed. Show an error condition.
|
|
||||||
showError(reply.error());
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
QString reply = interface->call("RemoteMethod");
|
|
||||||
//! [1]
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
//! [0]
|
|
||||||
QPrinter pr;
|
|
||||||
if (pr.setup()) {
|
|
||||||
QPainter p(&pr);
|
|
||||||
canvas.drawArea(canvas.rect(), &p);
|
|
||||||
}
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
void MyCanvasView::contentsMousePressEvent(QMouseEvent* e)
|
|
||||||
{
|
|
||||||
Q3CanvasItemList l = canvas()->collisions(e->pos());
|
|
||||||
for (Q3CanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) {
|
|
||||||
if ((*it)->rtti() == Q3CanvasRectangle::RTTI)
|
|
||||||
qDebug("A Q3CanvasRectangle lies somewhere at this point");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//! [1]
|
|
||||||
|
|
||||||
|
|
||||||
//! [2]
|
|
||||||
QMatrix wm;
|
|
||||||
wm.scale(2, 2); // Zooms in by 2 times
|
|
||||||
wm.rotate(90); // Rotates 90 degrees counter clockwise
|
|
||||||
// around the origin.
|
|
||||||
wm.translate(0, -canvas->height());
|
|
||||||
// moves the canvas down so what was visible
|
|
||||||
// before is still visible.
|
|
||||||
myCanvasView->setWorldMatrix(wm);
|
|
||||||
//! [2]
|
|
||||||
|
|
||||||
|
|
||||||
//! [3]
|
|
||||||
QRect rc = QRect(myCanvasView->contentsX(), myCanvasView->contentsY(),
|
|
||||||
myCanvasView->visibleWidth(), myCanvasView->visibleHeight());
|
|
||||||
QRect canvasRect = myCanvasView->inverseWorldMatrix().mapRect(rc);
|
|
||||||
//! [3]
|
|
||||||
|
|
||||||
|
|
||||||
//! [4]
|
|
||||||
Q3CanvasItem* item;
|
|
||||||
// Find an item, e.g. with Q3CanvasItem::collisions().
|
|
||||||
...
|
|
||||||
if (item->rtti() == MySprite::RTTI) {
|
|
||||||
MySprite* s = (MySprite*)item;
|
|
||||||
if (s->isDamagable()) s->loseHitPoints(1000);
|
|
||||||
if (s->isHot()) myself->loseHitPoints(1000);
|
|
||||||
...
|
|
||||||
}
|
|
||||||
//! [4]
|
|
||||||
|
|
@ -1,229 +0,0 @@
|
||||||
//! [0]
|
|
||||||
QString s = Q3FileDialog::getOpenFileName(
|
|
||||||
"/home",
|
|
||||||
"Images (*.png *.xpm *.jpg)",
|
|
||||||
this,
|
|
||||||
"open file dialog",
|
|
||||||
"Choose a file");
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
"Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"
|
|
||||||
//! [1]
|
|
||||||
|
|
||||||
|
|
||||||
//! [2]
|
|
||||||
Q3FileDialog* fd = new Q3FileDialog(this, "file dialog", true);
|
|
||||||
fd->setMode(Q3FileDialog::AnyFile);
|
|
||||||
//! [2]
|
|
||||||
|
|
||||||
|
|
||||||
//! [3]
|
|
||||||
fd->setFilter("Images (*.png *.xpm *.jpg)");
|
|
||||||
//! [3]
|
|
||||||
|
|
||||||
|
|
||||||
//! [4]
|
|
||||||
fd->setViewMode(Q3FileDialog::Detail);
|
|
||||||
//! [4]
|
|
||||||
|
|
||||||
|
|
||||||
//! [5]
|
|
||||||
QString fileName;
|
|
||||||
if (fd->exec() == QDialog::Accepted)
|
|
||||||
fileName = fd->selectedFile();
|
|
||||||
//! [5]
|
|
||||||
|
|
||||||
|
|
||||||
//! [6]
|
|
||||||
class Preview : public QLabel, public Q3FilePreview
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Preview(QWidget *parent=0) : QLabel(parent) {}
|
|
||||||
|
|
||||||
void previewUrl(const Q3Url &u)
|
|
||||||
{
|
|
||||||
QString path = u.path();
|
|
||||||
QPixmap pix(path);
|
|
||||||
if (pix.isNull())
|
|
||||||
setText("This is not a pixmap");
|
|
||||||
else
|
|
||||||
setPixmap(pix);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
//! [6]
|
|
||||||
|
|
||||||
|
|
||||||
//! [7]
|
|
||||||
Preview* p = new Preview;
|
|
||||||
|
|
||||||
Q3FileDialog* fd = new Q3FileDialog(this);
|
|
||||||
fd->setContentsPreviewEnabled(true);
|
|
||||||
fd->setContentsPreview(p, p);
|
|
||||||
fd->setPreviewMode(Q3FileDialog::Contents);
|
|
||||||
fd->show();
|
|
||||||
//! [7]
|
|
||||||
|
|
||||||
|
|
||||||
//! [8]
|
|
||||||
QStringList list = myFileDialog.selectedFiles();
|
|
||||||
QStringList::Iterator it = list.begin();
|
|
||||||
while(it != list.end()) {
|
|
||||||
myProcessing(*it);
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
//! [8]
|
|
||||||
|
|
||||||
|
|
||||||
//! [9]
|
|
||||||
fd->setFilter("All C++ files (*.cpp *.cc *.C *.cxx *.c++)");
|
|
||||||
fd->setFilter("*.cpp *.cc *.C *.cxx *.c++");
|
|
||||||
fd->setFilter("All C++ files (*.cpp;*.cc;*.C;*.cxx;*.c++)");
|
|
||||||
fd->setFilter("*.cpp;*.cc;*.C;*.cxx;*.c++");
|
|
||||||
//! [9]
|
|
||||||
|
|
||||||
|
|
||||||
//! [10]
|
|
||||||
QString s = Q3FileDialog::getOpenFileName(
|
|
||||||
"/home",
|
|
||||||
"Images (*.png *.xpm *.jpg)",
|
|
||||||
this,
|
|
||||||
"open file dialog",
|
|
||||||
"Choose a file to open");
|
|
||||||
//! [10]
|
|
||||||
|
|
||||||
|
|
||||||
//! [11]
|
|
||||||
QString s = Q3FileDialog::getSaveFileName(
|
|
||||||
"/home",
|
|
||||||
"Images (*.png *.xpm *.jpg)",
|
|
||||||
this,
|
|
||||||
"save file dialog",
|
|
||||||
"Choose a filename to save under");
|
|
||||||
//! [11]
|
|
||||||
|
|
||||||
|
|
||||||
//! [12]
|
|
||||||
QString s = Q3FileDialog::getExistingDirectory(
|
|
||||||
"/home",
|
|
||||||
this,
|
|
||||||
"get existing directory",
|
|
||||||
"Choose a directory",
|
|
||||||
true);
|
|
||||||
//! [12]
|
|
||||||
|
|
||||||
|
|
||||||
//! [13]
|
|
||||||
MyFileDialog::MyFileDialog(QWidget* parent, const char* name) :
|
|
||||||
Q3FileDialog(parent, name)
|
|
||||||
{
|
|
||||||
QLabel* label = new QLabel("Added widgets", this);
|
|
||||||
QLineEdit* lineedit = new QLineEdit(this);
|
|
||||||
QPushButton* pushbutton = new QPushButton(this);
|
|
||||||
|
|
||||||
addWidgets(label, lineedit, pushbutton);
|
|
||||||
}
|
|
||||||
//! [13]
|
|
||||||
|
|
||||||
|
|
||||||
//! [14]
|
|
||||||
QString types("Image files (*.png *.xpm *.jpg);;"
|
|
||||||
"Text files (*.txt);;"
|
|
||||||
"Any files (*)");
|
|
||||||
Q3FileDialog fd = new Q3FileDialog(this);
|
|
||||||
fd->setFilters(types);
|
|
||||||
fd->show();
|
|
||||||
//! [14]
|
|
||||||
|
|
||||||
|
|
||||||
//! [15]
|
|
||||||
Q3FileDialog* fd = new Q3FileDialog(this);
|
|
||||||
fd->addFilter("Images (*.png *.jpg *.xpm)");
|
|
||||||
fd->show();
|
|
||||||
//! [15]
|
|
||||||
|
|
||||||
|
|
||||||
//! [16]
|
|
||||||
QStringList files = Q3FileDialog::getOpenFileNames(
|
|
||||||
"Images (*.png *.xpm *.jpg)",
|
|
||||||
"/home",
|
|
||||||
this,
|
|
||||||
"open files dialog",
|
|
||||||
"Select one or more files to open");
|
|
||||||
//! [16]
|
|
||||||
|
|
||||||
|
|
||||||
//! [17]
|
|
||||||
QStringList list = files;
|
|
||||||
QStringList::Iterator it = list.begin();
|
|
||||||
while(it != list.end()) {
|
|
||||||
myProcessing(*it);
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
//! [17]
|
|
||||||
|
|
||||||
|
|
||||||
//! [18]
|
|
||||||
class Preview : public QLabel, public Q3FilePreview
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Preview(QWidget *parent=0) : QLabel(parent) {}
|
|
||||||
|
|
||||||
void previewUrl(const Q3Url &u)
|
|
||||||
{
|
|
||||||
QString path = u.path();
|
|
||||||
QPixmap pix(path);
|
|
||||||
if (pix.isNull())
|
|
||||||
setText("This is not a pixmap");
|
|
||||||
else
|
|
||||||
setText("This is a pixmap");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//...
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
Preview* p = new Preview;
|
|
||||||
|
|
||||||
Q3FileDialog* fd = new Q3FileDialog(this);
|
|
||||||
fd->setInfoPreviewEnabled(true);
|
|
||||||
fd->setInfoPreview(p, p);
|
|
||||||
fd->setPreviewMode(Q3FileDialog::Info);
|
|
||||||
fd->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
//! [18]
|
|
||||||
|
|
||||||
|
|
||||||
//! [19]
|
|
||||||
class Preview : public QLabel, public Q3FilePreview
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Preview(QWidget *parent=0) : QLabel(parent) {}
|
|
||||||
|
|
||||||
void previewUrl(const Q3Url &u)
|
|
||||||
{
|
|
||||||
QString path = u.path();
|
|
||||||
QPixmap pix(path);
|
|
||||||
if (pix.isNull())
|
|
||||||
setText("This is not a pixmap");
|
|
||||||
else
|
|
||||||
setPixmap(pix);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//...
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
Preview* p = new Preview;
|
|
||||||
|
|
||||||
Q3FileDialog* fd = new Q3FileDialog(this);
|
|
||||||
fd->setContentsPreviewEnabled(true);
|
|
||||||
fd->setContentsPreview(p, p);
|
|
||||||
fd->setPreviewMode(Q3FileDialog::Contents);
|
|
||||||
fd->show();
|
|
||||||
}
|
|
||||||
//! [19]
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
//! [0]
|
|
||||||
Q3ProgressDialog progress("Copying files...", "Abort Copy", numFiles,
|
|
||||||
this, "progress", true);
|
|
||||||
for (int i = 0; i < numFiles; i++) {
|
|
||||||
progress.setProgress(i);
|
|
||||||
qApp->processEvents();
|
|
||||||
|
|
||||||
if (progress.wasCanceled())
|
|
||||||
break;
|
|
||||||
//... copy one file
|
|
||||||
}
|
|
||||||
progress.setProgress(numFiles);
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
Operation::Operation(QObject *parent = 0)
|
|
||||||
: QObject(parent), steps(0)
|
|
||||||
{
|
|
||||||
pd = new Q3ProgressDialog("Operation in progress.", "Cancel", 100);
|
|
||||||
connect(pd, SIGNAL(canceled()), this, SLOT(cancel()));
|
|
||||||
t = new QTimer(this);
|
|
||||||
connect(t, SIGNAL(timeout()), this, SLOT(perform()));
|
|
||||||
t->start(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Operation::perform()
|
|
||||||
{
|
|
||||||
pd->setProgress(steps);
|
|
||||||
//... perform one percent of the operation
|
|
||||||
steps++;
|
|
||||||
if (steps > pd->totalSteps())
|
|
||||||
t->stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Operation::cancel()
|
|
||||||
{
|
|
||||||
t->stop();
|
|
||||||
//... cleanup
|
|
||||||
}
|
|
||||||
//! [1]
|
|
||||||
|
|
@ -1,75 +0,0 @@
|
||||||
//! [0]
|
|
||||||
(void) new Q3IconViewItem(
|
|
||||||
iconView, // A pointer to a Q3IconView
|
|
||||||
"This is the text of the item",
|
|
||||||
aPixmap);
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
Q3IconViewItem *item;
|
|
||||||
for (item = iconView->firstItem(); item; item = item->nextItem())
|
|
||||||
do_something_with(item);
|
|
||||||
//! [1]
|
|
||||||
|
|
||||||
|
|
||||||
//! [2]
|
|
||||||
Q3IconViewItem *item;
|
|
||||||
for (item = iconView->firstItem(); item; item = item->nextItem())
|
|
||||||
do_something_with(item);
|
|
||||||
//! [2]
|
|
||||||
|
|
||||||
|
|
||||||
//! [3]
|
|
||||||
int MyIconViewItem::compare(Q3IconViewItem *i) const
|
|
||||||
{
|
|
||||||
return key().compare(i->key());
|
|
||||||
}
|
|
||||||
//! [3]
|
|
||||||
|
|
||||||
|
|
||||||
//! [4]
|
|
||||||
Q3IconView *iv = new Q3IconView(this);
|
|
||||||
QDir dir(path, "*.xpm");
|
|
||||||
for (uint i = 0; i < dir.count(); i++) {
|
|
||||||
(void) new Q3IconViewItem(iv, dir[i], QPixmap(path + dir[i]));
|
|
||||||
}
|
|
||||||
iv->resize(600, 400);
|
|
||||||
iv->show();
|
|
||||||
//! [4]
|
|
||||||
|
|
||||||
|
|
||||||
//! [5]
|
|
||||||
for (Q3IconViewItem *item = iv->firstItem(); item; item = item->nextItem())
|
|
||||||
do_something(item);
|
|
||||||
//! [5]
|
|
||||||
|
|
||||||
|
|
||||||
//! [6]
|
|
||||||
Q3DragObject *MyIconView::dragObject()
|
|
||||||
{
|
|
||||||
return new Q3TextDrag(currentItem()->text(), this);
|
|
||||||
}
|
|
||||||
//! [6]
|
|
||||||
|
|
||||||
|
|
||||||
//! [7]
|
|
||||||
bool MyIconViewItem::acceptDrop(const QMimeSource *mime) const
|
|
||||||
{
|
|
||||||
if (mime->provides("text/plain"))
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MyIconViewItem::dropped(QDropEvent *evt, const Q3ValueList<Q3IconDragItem>&)
|
|
||||||
{
|
|
||||||
QString label;
|
|
||||||
if (Q3TextDrag::decode(evt, label))
|
|
||||||
setText(label);
|
|
||||||
}
|
|
||||||
//! [7]
|
|
||||||
|
|
||||||
|
|
||||||
//! [8]
|
|
||||||
(void) new Q3IconViewItem(myIconview, "The text of the item", aPixmap);
|
|
||||||
//! [8]
|
|
||||||
|
|
@ -1,73 +0,0 @@
|
||||||
//! [0]
|
|
||||||
(void) new Q3ListViewItem(listView, "Column 1", "Column 2");
|
|
||||||
(void) new Q3ListViewItem(listView->firstChild(), "A", "B", "C");
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
Q3ListViewItem * myChild = myItem->firstChild();
|
|
||||||
while(myChild) {
|
|
||||||
doSomething(myChild);
|
|
||||||
myChild = myChild->nextSibling();
|
|
||||||
}
|
|
||||||
//! [1]
|
|
||||||
|
|
||||||
|
|
||||||
//! [2]
|
|
||||||
Q3ListViewItemIterator it(listview);
|
|
||||||
while (it.current()) {
|
|
||||||
Q3ListViewItem *item = it.current();
|
|
||||||
doSomething(item);
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
//! [2]
|
|
||||||
|
|
||||||
|
|
||||||
//! [3]
|
|
||||||
int MyListViewItem::compare(Q3ListViewItem *i, int col,
|
|
||||||
bool ascending) const
|
|
||||||
{
|
|
||||||
return key(col, ascending).compare(i->key(col, ascending));
|
|
||||||
}
|
|
||||||
//! [3]
|
|
||||||
|
|
||||||
|
|
||||||
//! [4]
|
|
||||||
Q3ListViewItem *i = itemAt(p);
|
|
||||||
if (i) {
|
|
||||||
if (p.x() > header()->sectionPos(header()->mapToIndex(0)) +
|
|
||||||
treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + itemMargin() ||
|
|
||||||
p.x() < header()->sectionPos(header()->mapToIndex(0))) {
|
|
||||||
; // p is not on root decoration
|
|
||||||
else
|
|
||||||
; // p is on the root decoration
|
|
||||||
}
|
|
||||||
//! [4]
|
|
||||||
|
|
||||||
|
|
||||||
//! [5]
|
|
||||||
QRect r(listView->itemRect(item));
|
|
||||||
r.setHeight(qMin(item->totalHeight(),
|
|
||||||
listView->viewport->height() - r.y()))
|
|
||||||
//! [5]
|
|
||||||
|
|
||||||
|
|
||||||
//! [6]
|
|
||||||
QList<Q3ListViewItem *> lst;
|
|
||||||
Q3ListViewItemIterator it(myListView);
|
|
||||||
while (it.current()) {
|
|
||||||
if (it.current()->isSelected())
|
|
||||||
lst.append(it.current());
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
//! [6]
|
|
||||||
|
|
||||||
|
|
||||||
//! [7]
|
|
||||||
QList<Q3ListViewItem *> lst;
|
|
||||||
Q3ListViewItemIterator it(myListView, Selected);
|
|
||||||
while (it.current()) {
|
|
||||||
lst.append(it.current());
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
//! [7]
|
|
||||||
|
|
@ -1,57 +0,0 @@
|
||||||
|
|
||||||
void wrapInFunction()
|
|
||||||
{
|
|
||||||
|
|
||||||
//! [0]
|
|
||||||
for (int row = 0; row < table->numRows(); row++) {
|
|
||||||
for (int col = 0; col < table->numCols(); col++) {
|
|
||||||
table->setItem(row, col,
|
|
||||||
new Q3TableItem(table, Q3TableItem::WhenCurrent, QString::number(row * col)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
QWidget* MyTableItem::createEditor() const
|
|
||||||
{
|
|
||||||
QHBox* hbox = new QHBox(table()->viewport());
|
|
||||||
hbox->setFocusProxy(new QLineEdit(hbox));
|
|
||||||
new QLineEdit(hbox);
|
|
||||||
return hbox;
|
|
||||||
}
|
|
||||||
//! [1]
|
|
||||||
|
|
||||||
|
|
||||||
//! [2]
|
|
||||||
p->setClipRect(table()->cellRect(row, col), QPainter::ClipPainter);
|
|
||||||
//... your drawing code
|
|
||||||
p->setClipping(false);
|
|
||||||
//! [2]
|
|
||||||
|
|
||||||
|
|
||||||
//! [3]
|
|
||||||
Q3Table *table = new Q3Table(100, 250, this);
|
|
||||||
table->setPixmap(3, 2, pix);
|
|
||||||
table->setText(3, 2, "A pixmap");
|
|
||||||
//! [3]
|
|
||||||
|
|
||||||
|
|
||||||
//! [4]
|
|
||||||
p->setClipRect(cellRect(row, col), QPainter::CoordPainter);
|
|
||||||
//... your drawing code
|
|
||||||
p->setClipping(false);
|
|
||||||
//! [4]
|
|
||||||
|
|
||||||
|
|
||||||
//! [5]
|
|
||||||
Q3TableItem *i = item(row, col);
|
|
||||||
if (initFromCell || (i && !i->isReplaceable()))
|
|
||||||
// If we had a Q3TableItem ask the base class to create the editor
|
|
||||||
return Q3Table::createEditor(row, col, initFromCell);
|
|
||||||
else
|
|
||||||
return ...(create your own editor)
|
|
||||||
//! [5]
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
//! [0]
|
|
||||||
QStringList list = myDns.qualifiedNames();
|
|
||||||
QStringList::Iterator it = list.begin();
|
|
||||||
while( it != list.end() ) {
|
|
||||||
myProcessing( *it );
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
Q3ValueList<QHostAddress> list = myDns.addresses();
|
|
||||||
Q3ValueList<QHostAddress>::Iterator it = list.begin();
|
|
||||||
while( it != list.end() ) {
|
|
||||||
myProcessing( *it );
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
//! [1]
|
|
||||||
|
|
||||||
|
|
||||||
//! [2]
|
|
||||||
Q3ValueList<Q3Dns::MailServer> list = myDns.mailServers();
|
|
||||||
Q3ValueList<Q3Dns::MailServer>::Iterator it = list.begin();
|
|
||||||
while( it != list.end() ) {
|
|
||||||
myProcessing( *it );
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
//! [2]
|
|
||||||
|
|
||||||
|
|
||||||
//! [3]
|
|
||||||
Q3ValueList<Q3Dns::Server> list = myDns.servers();
|
|
||||||
Q3ValueList<Q3Dns::Server>::Iterator it = list.begin();
|
|
||||||
while( it != list.end() ) {
|
|
||||||
myProcessing( *it );
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
//! [3]
|
|
||||||
|
|
||||||
|
|
||||||
//! [4]
|
|
||||||
QStringList list = myDns.hostNames();
|
|
||||||
QStringList::Iterator it = list.begin();
|
|
||||||
while( it != list.end() ) {
|
|
||||||
myProcessing( *it );
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
//! [4]
|
|
||||||
|
|
||||||
|
|
||||||
//! [5]
|
|
||||||
QStringList list = myDns.texts();
|
|
||||||
QStringList::Iterator it = list.begin();
|
|
||||||
while( it != list.end() ) {
|
|
||||||
myProcessing( *it );
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
//! [5]
|
|
||||||
|
|
@ -1,65 +0,0 @@
|
||||||
//! [0]
|
|
||||||
QUrlOperator op( "ftp://ftp.trolltech.com" );
|
|
||||||
op.listChildren(); // Asks the server to provide a directory listing
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
Q3Ftp *ftp = new Q3Ftp( this ); // this is an optional QObject parent
|
|
||||||
ftp->connectToHost( "ftp.trolltech.com" );
|
|
||||||
ftp->login();
|
|
||||||
//! [1]
|
|
||||||
|
|
||||||
|
|
||||||
//! [2]
|
|
||||||
ftp->connectToHost( "ftp.trolltech.com" ); // id == 1
|
|
||||||
ftp->login(); // id == 2
|
|
||||||
ftp->cd( "qt" ); // id == 3
|
|
||||||
ftp->get( "INSTALL" ); // id == 4
|
|
||||||
ftp->close(); // id == 5
|
|
||||||
//! [2]
|
|
||||||
|
|
||||||
|
|
||||||
//! [3]
|
|
||||||
start( 1 )
|
|
||||||
stateChanged( HostLookup )
|
|
||||||
stateChanged( Connecting )
|
|
||||||
stateChanged( Connected )
|
|
||||||
finished( 1, false )
|
|
||||||
|
|
||||||
start( 2 )
|
|
||||||
stateChanged( LoggedIn )
|
|
||||||
finished( 2, false )
|
|
||||||
|
|
||||||
start( 3 )
|
|
||||||
finished( 3, false )
|
|
||||||
|
|
||||||
start( 4 )
|
|
||||||
dataTransferProgress( 0, 3798 )
|
|
||||||
dataTransferProgress( 2896, 3798 )
|
|
||||||
readyRead()
|
|
||||||
dataTransferProgress( 3798, 3798 )
|
|
||||||
readyRead()
|
|
||||||
finished( 4, false )
|
|
||||||
|
|
||||||
start( 5 )
|
|
||||||
stateChanged( Closing )
|
|
||||||
stateChanged( Unconnected )
|
|
||||||
finished( 5, false )
|
|
||||||
|
|
||||||
done( false )
|
|
||||||
//! [3]
|
|
||||||
|
|
||||||
|
|
||||||
//! [4]
|
|
||||||
start( 1 )
|
|
||||||
stateChanged( HostLookup )
|
|
||||||
stateChanged( Connecting )
|
|
||||||
stateChanged( Connected )
|
|
||||||
finished( 1, false )
|
|
||||||
|
|
||||||
start( 2 )
|
|
||||||
finished( 2, true )
|
|
||||||
|
|
||||||
done( true )
|
|
||||||
//! [4]
|
|
||||||
|
|
@ -1,74 +0,0 @@
|
||||||
//! [0]
|
|
||||||
content-type: text/html
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
header.setValue( "content-type", "text/html" );
|
|
||||||
QString contentType = header.value( "content-type" );
|
|
||||||
//! [1]
|
|
||||||
|
|
||||||
|
|
||||||
//! [2]
|
|
||||||
QUrlOperator op( "http://qtsoftware.com" );
|
|
||||||
op.get( "index.html" );
|
|
||||||
//! [2]
|
|
||||||
|
|
||||||
|
|
||||||
//! [3]
|
|
||||||
Q3HttpRequestHeader header( "GET", "/index.html" );
|
|
||||||
header.setValue( "Host", "qtsoftware.com" );
|
|
||||||
http->setHost( "qtsoftware.com" );
|
|
||||||
http->request( header );
|
|
||||||
//! [3]
|
|
||||||
|
|
||||||
|
|
||||||
//! [4]
|
|
||||||
http->setHost( "qtsoftware.com" ); // id == 1
|
|
||||||
http->get( "/index.html" ); // id == 2
|
|
||||||
//! [4]
|
|
||||||
|
|
||||||
|
|
||||||
//! [5]
|
|
||||||
requestStarted( 1 )
|
|
||||||
requestFinished( 1, false )
|
|
||||||
|
|
||||||
requestStarted( 2 )
|
|
||||||
stateChanged( Connecting )
|
|
||||||
stateChanged( Sending )
|
|
||||||
dataSendProgress( 77, 77 )
|
|
||||||
stateChanged( Reading )
|
|
||||||
responseHeaderReceived( responseheader )
|
|
||||||
dataReadProgress( 5388, 0 )
|
|
||||||
readyRead( responseheader )
|
|
||||||
dataReadProgress( 18300, 0 )
|
|
||||||
readyRead( responseheader )
|
|
||||||
stateChanged( Connected )
|
|
||||||
requestFinished( 2, false )
|
|
||||||
|
|
||||||
done( false )
|
|
||||||
|
|
||||||
stateChanged( Closing )
|
|
||||||
stateChanged( Unconnected )
|
|
||||||
//! [5]
|
|
||||||
|
|
||||||
|
|
||||||
//! [6]
|
|
||||||
http->setHost( "www.foo.bar" ); // id == 1
|
|
||||||
http->get( "/index.html" ); // id == 2
|
|
||||||
http->post( "register.html", data ); // id == 3
|
|
||||||
//! [6]
|
|
||||||
|
|
||||||
|
|
||||||
//! [7]
|
|
||||||
requestStarted( 1 )
|
|
||||||
requestFinished( 1, false )
|
|
||||||
|
|
||||||
requestStarted( 2 )
|
|
||||||
stateChanged( HostLookup )
|
|
||||||
requestFinished( 2, true )
|
|
||||||
|
|
||||||
done( true )
|
|
||||||
|
|
||||||
stateChanged( Unconnected )
|
|
||||||
//! [7]
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
//! [0]
|
|
||||||
Q3UrlOperator op( "file:///tmp" );
|
|
||||||
op.listChildren(); // Asks the server to provide a directory listing
|
|
||||||
//! [0]
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//! [0]
|
|
||||||
Q3NetworkProtocol::registerNetworkProtocol( "nntp", new Q3NetworkProtocolFactory<Nntp> );
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
Q3Ftp *ftp = Q3NetworkProtocol::getNetworkProtocol( "ftp" );
|
|
||||||
//! [1]
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
//! [0]
|
|
||||||
while( !socket->canReadLine() ) // WRONG
|
|
||||||
;
|
|
||||||
//! [0]
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
//! [0]
|
|
||||||
::close( sd->socket() );
|
|
||||||
sd->writeBlock( someData, 42 );
|
|
||||||
//! [0]
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
//! [0]
|
|
||||||
Q3Url url( "http://qtsoftware.com" );
|
|
||||||
// or
|
|
||||||
Q3Url url( "file:///home/myself/Mail", "Inbox" );
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
Q3Url url( "http://qtsoftware.com" );
|
|
||||||
QString s = url;
|
|
||||||
// or
|
|
||||||
QString s( "http://qtsoftware.com" );
|
|
||||||
Q3Url url( s );
|
|
||||||
//! [1]
|
|
||||||
|
|
||||||
|
|
||||||
//! [2]
|
|
||||||
Q3Url url( "ftp://ftp.trolltech.com/qt/source", "qt-2.1.0.tar.gz" );
|
|
||||||
//! [2]
|
|
||||||
|
|
||||||
|
|
||||||
//! [3]
|
|
||||||
Q3Url url( "ftp://ftp.trolltech.com/qt/source", "/usr/local" );
|
|
||||||
//! [3]
|
|
||||||
|
|
||||||
|
|
||||||
//! [4]
|
|
||||||
Q3Url url( "ftp://ftp.trolltech.com/qt/source", "file:///usr/local" );
|
|
||||||
//! [4]
|
|
||||||
|
|
||||||
|
|
||||||
//! [5]
|
|
||||||
QString url = http://qtsoftware.com
|
|
||||||
Q3Url::encode( url );
|
|
||||||
// url is now "http%3A//www%20trolltech%20com"
|
|
||||||
//! [5]
|
|
||||||
|
|
||||||
|
|
||||||
//! [6]
|
|
||||||
QString url = "http%3A//www%20trolltech%20com"
|
|
||||||
Q3Url::decode( url );
|
|
||||||
// url is now "http://qtsoftware.com"
|
|
||||||
//! [6]
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
//! [0]
|
|
||||||
Q3UrlOperator *op = new Q3UrlOperator();
|
|
||||||
op->copy( QString("ftp://ftp.trolltech.com/qt/source/qt-2.1.0.tar.gz"),
|
|
||||||
"file:///tmp" );
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
Q3UrlOperator op( "http://www.whatever.org/cgi-bin/search.pl?cmd=Hello" );
|
|
||||||
op.get();
|
|
||||||
//! [1]
|
|
||||||
|
|
||||||
|
|
||||||
//! [2]
|
|
||||||
Q3UrlOperator op( "ftp://ftp.whatever.org/pub" );
|
|
||||||
// do some other stuff like op.listChildren() or op.mkdir( "new_dir" )
|
|
||||||
op.get( "a_file.txt" );
|
|
||||||
//! [2]
|
|
||||||
|
|
||||||
|
|
||||||
//! [3]
|
|
||||||
Q3UrlOperator op( "http://www.whatever.org/cgi-bin" );
|
|
||||||
op.get( "search.pl?cmd=Hello" ); // WRONG!
|
|
||||||
//! [3]
|
|
||||||
|
|
||||||
|
|
||||||
//! [4]
|
|
||||||
Q3UrlOperator op( "ftp://ftp.whatever.com/home/me/filename.dat" );
|
|
||||||
op.put( data );
|
|
||||||
//! [4]
|
|
||||||
|
|
||||||
|
|
||||||
//! [5]
|
|
||||||
Q3UrlOperator op( "ftp://ftp.whatever.com/home/me" );
|
|
||||||
// do some other stuff like op.listChildren() or op.mkdir( "new_dir" )
|
|
||||||
op.put( data, "filename.dat" );
|
|
||||||
//! [5]
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
//! [0]
|
|
||||||
QPushButton p("&Exit", parent); // automatic shortcut Alt+E
|
|
||||||
Q3PopupMenu *fileMenu = new fileMenu(parent);
|
|
||||||
fileMenu->insertItem("Undo", parent, SLOT(undo()),
|
|
||||||
Qt::CTRL + Qt::Key_Z);
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
accelerator->insertItem(QKeySequence("M"));
|
|
||||||
//! [1]
|
|
||||||
|
|
||||||
|
|
||||||
//! [2]
|
|
||||||
Q3Accel *a = new Q3Accel(myWindow);
|
|
||||||
a->connectItem(a->insertItem(Qt::CTRL + Qt::Key_P),
|
|
||||||
myWindow, SLOT(printDoc()));
|
|
||||||
//! [2]
|
|
||||||
|
|
||||||
|
|
||||||
//! [3]
|
|
||||||
Q3Accel *a = new Q3Accel(myWindow); // create accels for myWindow
|
|
||||||
a->insertItem(CTRL + Key_P, 200); // Ctrl+P, e.g. to print document
|
|
||||||
a->insertItem(ALT + Key_X, 201); // Alt+X, e.g. to quit
|
|
||||||
a->insertItem(UNICODE_ACCEL + 'q', 202); // Unicode 'q', e.g. to quit
|
|
||||||
a->insertItem(Key_D); // gets a unique negative id < -1
|
|
||||||
a->insertItem(CTRL + SHIFT + Key_P); // gets a unique negative id < -1
|
|
||||||
//! [3]
|
|
||||||
|
|
||||||
|
|
||||||
//! [4]
|
|
||||||
a->connectItem(201, mainView, SLOT(quit()));
|
|
||||||
//! [4]
|
|
||||||
|
|
||||||
|
|
||||||
//! [5]
|
|
||||||
Q3PopupMenu *file = new Q3PopupMenu(this);
|
|
||||||
file->insertItem(p1, tr("&Open..."), this, SLOT(open()),
|
|
||||||
Q3Accel::stringToKey(tr("Ctrl+O", "File|Open")));
|
|
||||||
//! [5]
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
//! [0]
|
|
||||||
static const char* myimage_data[]={
|
|
||||||
"...",
|
|
||||||
...
|
|
||||||
"..."};
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
Q3MimeSourceFactory::defaultFactory()->setImage("myimage", QImage(myimage_data));
|
|
||||||
//! [1]
|
|
||||||
|
|
||||||
|
|
||||||
//! [2]
|
|
||||||
QLabel* label = new QLabel(
|
|
||||||
"Rich text with embedded image:<img source=\"myimage\">"
|
|
||||||
"Isn't that <em>cute</em>?");
|
|
||||||
//! [2]
|
|
||||||
|
|
||||||
|
|
||||||
//! [3]
|
|
||||||
delete label;
|
|
||||||
Q3MimeSourceFactory::defaultFactory()->setData("myimage", 0);
|
|
||||||
//! [3]
|
|
||||||
|
|
||||||
|
|
||||||
//! [4]
|
|
||||||
setExtensionType("html", "text/html;charset=iso8859-1");
|
|
||||||
setExtensionType("htm", "text/html;charset=iso8859-1");
|
|
||||||
setExtensionType("txt", "text/plain");
|
|
||||||
setExtensionType("xml", "text/xml;charset=UTF-8");
|
|
||||||
//! [4]
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//! [0]
|
|
||||||
QStringList list = myProcess.arguments();
|
|
||||||
QStringList::Iterator it = list.begin();
|
|
||||||
while( it != list.end() ) {
|
|
||||||
myProcessing( *it );
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
//! [0]
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
//! [0]
|
|
||||||
process->tryTerminate();
|
|
||||||
QTimer::singleShot( 5000, process, SLOT(kill()) );
|
|
||||||
//! [0]
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
//! [0]
|
|
||||||
Q3PaintDeviceMetrics pdm(myWidget);
|
|
||||||
double aspect = (double)pdm.widthMM() / (double)pdm.heightMM();
|
|
||||||
//! [0]
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
//! [0]
|
|
||||||
QPainter p(myWidget);
|
|
||||||
p.drawArc(QRect(10,10, 70,100), 100*16, 160*16); // draws a "(" arc
|
|
||||||
//! [0]
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
//! [0]
|
|
||||||
Q3Picture picture;
|
|
||||||
picture.load("drawing.svg", SVG);
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
Q3Picture picture;
|
|
||||||
QPainter painter;
|
|
||||||
painter.begin(&picture); // paint in picture
|
|
||||||
...
|
|
||||||
painter.end(); // painting done
|
|
||||||
picture.save("drawing.svg", SVG); // save picture
|
|
||||||
//! [1]
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//! [0]
|
|
||||||
QStringList list = myDataBrowser.sort();
|
|
||||||
QStringList::Iterator it = list.begin();
|
|
||||||
while(it != list.end()) {
|
|
||||||
myProcessing(*it);
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
//! [0]
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//! [0]
|
|
||||||
QStringList list = myDataTable.sort();
|
|
||||||
QStringList::Iterator it = list.begin();
|
|
||||||
while( it != list.end() ) {
|
|
||||||
myProcessing( *it );
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
//! [0]
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
//! [0]
|
|
||||||
myView.setRecord(record);
|
|
||||||
myView.readFields();
|
|
||||||
//! [0]
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
//! [0]
|
|
||||||
QLineEdit myEditor(this);
|
|
||||||
Q3SqlForm myForm(this);
|
|
||||||
Q3SqlCursor myCursor("mytable");
|
|
||||||
|
|
||||||
// Execute a query to make the cursor valid
|
|
||||||
myCursor.select();
|
|
||||||
// Move the cursor to a valid record (the first record)
|
|
||||||
myCursor.next();
|
|
||||||
// Set the form's record pointer to the cursor's edit buffer (which
|
|
||||||
// contains the current record's values)
|
|
||||||
myForm.setRecord(myCursor.primeUpdate());
|
|
||||||
|
|
||||||
// Insert a field into the form that uses myEditor to edit the
|
|
||||||
// field 'somefield' in 'mytable'
|
|
||||||
myForm.insert(&myEditor, "somefield");
|
|
||||||
|
|
||||||
// Update myEditor with the value from the mapped database field
|
|
||||||
myForm.readFields();
|
|
||||||
...
|
|
||||||
// Let the user edit the form
|
|
||||||
...
|
|
||||||
// Update the database
|
|
||||||
myForm.writeFields(); // Update the cursor's edit buffer from the form
|
|
||||||
myCursor.update(); // Update the database from the cursor's buffer
|
|
||||||
//! [0]
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
//! [0]
|
|
||||||
Q3SqlCursor* myCursor = myManager.cursor();
|
|
||||||
...
|
|
||||||
QSqlRecord* buf = myCursor->primeUpdate();
|
|
||||||
buf->setValue("name", "Ola");
|
|
||||||
buf->setValue("city", "Oslo");
|
|
||||||
...
|
|
||||||
myCursor->update(); // update current record
|
|
||||||
myCursor->select(); // refresh the cursor
|
|
||||||
myManager.findBuffer(myCursor->primaryIndex()); // go to the updated record
|
|
||||||
//! [0]
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
//! [0]
|
|
||||||
Q3SqlPropertyMap *myMap = new Q3SqlPropertyMap();
|
|
||||||
Q3SqlForm *myForm = new Q3SqlForm(this);
|
|
||||||
MyEditor myEditor(this);
|
|
||||||
|
|
||||||
// Set the Q3SqlForm's record buffer to the update buffer of
|
|
||||||
// a pre-existing Q3SqlCursor called 'cur'.
|
|
||||||
myForm->setRecord(cur->primeUpdate());
|
|
||||||
|
|
||||||
// Install the customized map
|
|
||||||
myMap->insert("MyEditor", "content");
|
|
||||||
myForm->installPropertyMap(myMap); // myForm now owns myMap
|
|
||||||
...
|
|
||||||
// Insert a field into the form that uses a myEditor to edit the
|
|
||||||
// field 'somefield'
|
|
||||||
myForm->insert(&myEditor, "somefield");
|
|
||||||
|
|
||||||
// Update myEditor with the value from the mapped database field
|
|
||||||
myForm->readFields();
|
|
||||||
...
|
|
||||||
// Let the user edit the form
|
|
||||||
...
|
|
||||||
// Update the database fields with the values in the form
|
|
||||||
myForm->writeFields();
|
|
||||||
...
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
Q3SqlPropertyMap *myMap = new Q3SqlPropertyMap;
|
|
||||||
|
|
||||||
myMap->insert("MyEditor", "content");
|
|
||||||
Q3SqlPropertyMap::installDefaultMap(myMap);
|
|
||||||
...
|
|
||||||
//! [1]
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
//! [0]
|
|
||||||
...
|
|
||||||
Q3SqlSelectCursor* cur = new Q3SqlSelectCursor("SELECT id, firstname, lastname FROM author");
|
|
||||||
Q3DataTable* table = new Q3DataTable(this);
|
|
||||||
table->setSqlCursor(cur, true, true);
|
|
||||||
table->refresh();
|
|
||||||
...
|
|
||||||
cur->exec("SELECT * FROM books");
|
|
||||||
table->refresh();
|
|
||||||
...
|
|
||||||
//! [0]
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
//! [0]
|
|
||||||
Q3SimpleRichText myrichtext(contents, mywidget->font());
|
|
||||||
//! [0]
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
//! [0]
|
|
||||||
mimeSourceFactory()->setExtensionType("qml", "text/utf8");
|
|
||||||
//! [0]
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
//! [0]
|
|
||||||
QFile file(fileName); // Read the text from a file
|
|
||||||
if (file.open(IO_ReadOnly)) {
|
|
||||||
QTextStream stream(&file);
|
|
||||||
textEdit->setText(stream.read());
|
|
||||||
}
|
|
||||||
|
|
||||||
QFile file(fileName); // Write the text to a file
|
|
||||||
if (file.open(IO_WriteOnly)) {
|
|
||||||
QTextStream stream(&file);
|
|
||||||
stream << textEdit->text();
|
|
||||||
textEdit->setModified(false);
|
|
||||||
}
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
This is <font color=red>red</font> while <b>this</b> is <font color=blue>blue</font>.
|
|
||||||
<font color=green><font color=yellow>Yellow,</font> and <u>green</u>.
|
|
||||||
//! [1]
|
|
||||||
|
|
||||||
|
|
||||||
//! [2]
|
|
||||||
Q3TextEdit * log = new Q3TextEdit(this);
|
|
||||||
log->setTextFormat(Qt::LogText);
|
|
||||||
Q3StyleSheetItem * item = new Q3StyleSheetItem(log->styleSheet(), "mytag");
|
|
||||||
item->setColor("red");
|
|
||||||
item->setFontWeight(QFont::Bold);
|
|
||||||
item->setFontUnderline(true);
|
|
||||||
log->append("This is a <mytag>custom tag</mytag>!");
|
|
||||||
//! [2]
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
//! [0]
|
|
||||||
QString str;
|
|
||||||
Q3TextStream ts( &str, IO_WriteOnly );
|
|
||||||
ts << "pi = " << 3.14; // str == "pi = 3.14"
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
QString str = "pi = 3.14";
|
|
||||||
Q3TextStream ts( &str, IO_WriteOnly );
|
|
||||||
ts << "2+2 = " << 2+2; // str == "2+2 = 414"
|
|
||||||
//! [1]
|
|
||||||
|
|
||||||
|
|
||||||
//! [2]
|
|
||||||
QByteArray array;
|
|
||||||
Q3TextStream ts( array, IO_WriteOnly );
|
|
||||||
ts << "pi = " << 3.14 << '\0'; // array == "pi = 3.14"
|
|
||||||
//! [2]
|
|
||||||
|
|
||||||
|
|
||||||
//! [3]
|
|
||||||
QByteArray array;
|
|
||||||
QBuffer buf( array );
|
|
||||||
buf.open( IO_WriteOnly );
|
|
||||||
Q3TextStream ts( &buf );
|
|
||||||
ts << "pi = " << 3.14 << '\0'; // array == "pi = 3.14"
|
|
||||||
buf.close();
|
|
||||||
//! [3]
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
//! [0]
|
|
||||||
Q3CString str("helloworld", 6); // assigns "hello" to str
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
Q3CString a; // a.data() == 0, a.size() == 0, a.length() == 0
|
|
||||||
Q3CString b == ""; // b.data() == "", b.size() == 1, b.length() == 0
|
|
||||||
a.isNull(); // true because a.data() == 0
|
|
||||||
a.isEmpty(); // true because a.length() == 0
|
|
||||||
b.isNull(); // false because b.data() == ""
|
|
||||||
b.isEmpty(); // true because b.length() == 0
|
|
||||||
//! [1]
|
|
||||||
|
|
||||||
|
|
||||||
//! [2]
|
|
||||||
Q3CString s = "truncate this string";
|
|
||||||
s.truncate(5); // s == "trunc"
|
|
||||||
//! [2]
|
|
||||||
|
|
||||||
|
|
||||||
//! [3]
|
|
||||||
Q3CString s;
|
|
||||||
s.sprintf("%d - %s", 1, "first"); // result < 256 chars
|
|
||||||
|
|
||||||
Q3CString big(25000); // very long string
|
|
||||||
big.sprintf("%d - %s", 2, longString); // result < 25000 chars
|
|
||||||
//! [3]
|
|
||||||
|
|
||||||
|
|
||||||
//! [4]
|
|
||||||
Q3CString s("apple");
|
|
||||||
Q3CString t = s.leftJustify(8, '.'); // t == "apple..."
|
|
||||||
//! [4]
|
|
||||||
|
|
||||||
|
|
||||||
//! [5]
|
|
||||||
Q3CString s("pie");
|
|
||||||
Q3CString t = s.rightJustify(8, '.'); // t == ".....pie"
|
|
||||||
//! [5]
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
//! [0]
|
|
||||||
// all 5 strings share the same data
|
|
||||||
QString s1 = "abcd";
|
|
||||||
QString s2 = s1;
|
|
||||||
QString s3 = s2;
|
|
||||||
QString s4 = s3;
|
|
||||||
QString s5 = s2;
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
// s1, s2 and s5 share the same data, neither s3 nor s4 are shared
|
|
||||||
QString s1 = "abcd";
|
|
||||||
QString s2 = s1;
|
|
||||||
Q3DeepCopy<QString> s3 = s2; // s3 is a deep copy of s2
|
|
||||||
QString s4 = s3; // s4 is a deep copy of s3
|
|
||||||
QString s5 = s2;
|
|
||||||
//! [1]
|
|
||||||
|
|
||||||
|
|
||||||
//! [2]
|
|
||||||
// s1, s2 and s5 share the same data, s3 and s4 share the same data
|
|
||||||
QString s1 = "abcd";
|
|
||||||
QString s2 = s1;
|
|
||||||
QString s3 = Q3DeepCopy<QString>( s2 ); // s3 is a deep copy of s2
|
|
||||||
QString s4 = s3; // s4 is a shallow copy of s3
|
|
||||||
QString s5 = s2;
|
|
||||||
//! [2]
|
|
||||||
|
|
||||||
|
|
||||||
//! [3]
|
|
||||||
Q3DeepCopy<QString> global_string; // global string data
|
|
||||||
QMutex global_mutex; // mutex to protext global_string
|
|
||||||
|
|
||||||
...
|
|
||||||
|
|
||||||
void setGlobalString( const QString &str )
|
|
||||||
{
|
|
||||||
global_mutex.lock();
|
|
||||||
global_string = str; // global_string is a deep copy of str
|
|
||||||
global_mutex.unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
...
|
|
||||||
|
|
||||||
void MyThread::run()
|
|
||||||
{
|
|
||||||
global_mutex.lock();
|
|
||||||
QString str = global_string; // str is a deep copy of global_string
|
|
||||||
global_mutex.unlock();
|
|
||||||
|
|
||||||
// process the string data
|
|
||||||
...
|
|
||||||
|
|
||||||
// update global_string
|
|
||||||
setGlobalString( str );
|
|
||||||
}
|
|
||||||
//! [3]
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
//! [0]
|
|
||||||
static uchar bindata[] = { 231, 1, 44, ... };
|
|
||||||
QByteArray a;
|
|
||||||
a.setRawData(bindata, sizeof(bindata)); // a points to bindata
|
|
||||||
QDataStream s(a, IO_ReadOnly); // open on a's data
|
|
||||||
s >> <something>; // read raw bindata
|
|
||||||
s.close();
|
|
||||||
a.resetRawData(bindata, sizeof(bindata)); // finished
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
static uchar bindata[] = { 231, 1, 44, ... };
|
|
||||||
QByteArray a, b;
|
|
||||||
a.setRawData(bindata, sizeof(bindata)); // a points to bindata
|
|
||||||
a.resize(8); // will crash
|
|
||||||
b = a; // will crash
|
|
||||||
a[2] = 123; // might crash
|
|
||||||
// forget to resetRawData - will crash
|
|
||||||
//! [1]
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
//! [0]
|
|
||||||
#include <q3signal.h>
|
|
||||||
|
|
||||||
class MyClass
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MyClass();
|
|
||||||
~MyClass();
|
|
||||||
|
|
||||||
void doSomething();
|
|
||||||
|
|
||||||
void connect(QObject *receiver, const char *member);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Q3Signal *sig;
|
|
||||||
};
|
|
||||||
|
|
||||||
MyClass::MyClass()
|
|
||||||
{
|
|
||||||
sig = new Q3Signal;
|
|
||||||
}
|
|
||||||
|
|
||||||
MyClass::~MyClass()
|
|
||||||
{
|
|
||||||
delete sig;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MyClass::doSomething()
|
|
||||||
{
|
|
||||||
// ... does something
|
|
||||||
sig->activate(); // emits the signal
|
|
||||||
}
|
|
||||||
|
|
||||||
void MyClass::connect(QObject *receiver, const char *member)
|
|
||||||
{
|
|
||||||
sig->connect(receiver, member);
|
|
||||||
}
|
|
||||||
//! [0]
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
//! [0]
|
|
||||||
Q3ComboBox *c = new Q3ComboBox(this, tr("read-only combobox"));
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
Q3ComboBox *c1 = new Q3ComboBox(false, this, tr("read-only combobox"));
|
|
||||||
Q3ComboBox *c2 = new Q3ComboBox(true, this, tr("editable combobox"));
|
|
||||||
//! [1]
|
|
||||||
|
|
||||||
|
|
||||||
//! [2]
|
|
||||||
static const char* items[] = { "red", "green", "blue", 0 };
|
|
||||||
combo->insertStrList( items );
|
|
||||||
//! [2]
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
|
|
||||||
void wrapInFunction()
|
|
||||||
{
|
|
||||||
|
|
||||||
//! [0]
|
|
||||||
Q3DateEdit *dateEdit = new Q3DateEdit(QDate::currentDate(), this);
|
|
||||||
dateEdit->setRange(QDate::currentDate().addDays(-365),
|
|
||||||
QDate::currentDate().addDays( 365));
|
|
||||||
dateEdit->setOrder(Q3DateEdit::MDY);
|
|
||||||
dateEdit->setAutoAdvance(true);
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
QTime timeNow = QTime::currentTime();
|
|
||||||
Q3TimeEdit *timeEdit = new Q3TimeEdit(timeNow, this);
|
|
||||||
timeEdit->setRange(timeNow, timeNow.addSecs(60 * 60));
|
|
||||||
//! [1]
|
|
||||||
|
|
||||||
|
|
||||||
//! [2]
|
|
||||||
Q3DateTimeEdit *dateTimeEdit = new Q3DateTimeEdit(QDateTime::currentDateTime(), this);
|
|
||||||
dateTimeEdit->dateEdit()->setRange(QDateTime::currentDate(),
|
|
||||||
QDateTime::currentDate().addDays(7));
|
|
||||||
//! [2]
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
//! [0]
|
|
||||||
ts << *myDockArea;
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
ts >> *myDockArea;
|
|
||||||
//! [1]
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
//! [0]
|
|
||||||
Q3ToolBar *fileTools = new Q3ToolBar(this, "File Actions");
|
|
||||||
moveDockWindow(fileTools, Left);
|
|
||||||
//! [0]
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
//! [0]
|
|
||||||
p->setClipRect(cellRect(), QPainter::CoordPainter);
|
|
||||||
//... your drawing code
|
|
||||||
p->setClipping(false);
|
|
||||||
|
|
||||||
//! [0]
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
//! [0]
|
|
||||||
// Allow resizing of all current and future sections
|
|
||||||
header->setResizeEnabled(true);
|
|
||||||
// Disable resizing of section 3, (the fourth section added)
|
|
||||||
header->setResizeEnabled(false, 3);
|
|
||||||
//! [0]
|
|
||||||
|
|
@ -1,45 +0,0 @@
|
||||||
//! [0]
|
|
||||||
Q3MainWindow *mw = new Q3MainWindow;
|
|
||||||
QTextEdit *edit = new QTextEdit(mw, "editor");
|
|
||||||
edit->setFocus();
|
|
||||||
mw->setWindowTitle("Main Window");
|
|
||||||
mw->setCentralWidget(edit);
|
|
||||||
mw->show();
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
Q3ToolBar *tb = new Q3ToolBar(this);
|
|
||||||
addDockWindow(tb, tr("Menubar"), Top, false);
|
|
||||||
QMenuBar *mb = new QMenuBar(tb);
|
|
||||||
mb->setFrameStyle(QFrame::NoFrame);
|
|
||||||
tb->setStretchableWidget(mb);
|
|
||||||
setDockEnabled(tb, Left, false);
|
|
||||||
setDockEnabled(tb, Right, false);
|
|
||||||
//! [1]
|
|
||||||
|
|
||||||
|
|
||||||
//! [2]
|
|
||||||
QFile file(filename);
|
|
||||||
if (file.open(IO_WriteOnly)) {
|
|
||||||
QTextStream stream(&file);
|
|
||||||
stream << *mainWindow;
|
|
||||||
file.close();
|
|
||||||
}
|
|
||||||
//! [2]
|
|
||||||
|
|
||||||
|
|
||||||
//! [3]
|
|
||||||
QFile file(filename);
|
|
||||||
if (file.open(IO_ReadOnly)) {
|
|
||||||
QTextStream stream(&file);
|
|
||||||
stream >> *mainWindow;
|
|
||||||
file.close();
|
|
||||||
}
|
|
||||||
//! [3]
|
|
||||||
|
|
||||||
|
|
||||||
//! [4]
|
|
||||||
Q3PopupMenu * help = new Q3PopupMenu(this);
|
|
||||||
help->insertItem("What's &This", this , SLOT(enterWhatsThis()), Qt::SHIFT+Qt::Key_F1);
|
|
||||||
//! [4]
|
|
||||||
|
|
@ -1,61 +0,0 @@
|
||||||
//! [0]
|
|
||||||
Q3ScrollView* sv = new Q3ScrollView(...);
|
|
||||||
QWidget *widget = new QWidget(sv->viewport());
|
|
||||||
QVBoxLayout *layout = new QVBoxLayout(widget);
|
|
||||||
addChild(widget);
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
|
||||||
QLabel* child1 = new QLabel("CHILD", widget);
|
|
||||||
QLabel* child2 = new QLabel("CHILD", widget);
|
|
||||||
QLabel* child3 = new QLabel("CHILD", widget);
|
|
||||||
layout->addWidget(child1);
|
|
||||||
layout->addWidget(child2);
|
|
||||||
layout->addWidget(child3);
|
|
||||||
...
|
|
||||||
//! [1]
|
|
||||||
|
|
||||||
|
|
||||||
//! [2]
|
|
||||||
Q3ScrollView* sv = new Q3ScrollView(...);
|
|
||||||
QLabel* child1 = new QLabel("CHILD", sv->viewport());
|
|
||||||
sv->addChild(child1);
|
|
||||||
QLabel* child2 = new QLabel("CHILD", sv->viewport());
|
|
||||||
sv->addChild(child2);
|
|
||||||
QLabel* child3 = new QLabel("CHILD", sv->viewport());
|
|
||||||
sv->addChild(child3);
|
|
||||||
//! [2]
|
|
||||||
|
|
||||||
|
|
||||||
//! [3]
|
|
||||||
Q3ScrollView* sv = new Q3ScrollView(...);
|
|
||||||
sv->enableClipper(true);
|
|
||||||
QLabel* child1 = new QLabel("CHILD", sv->viewport());
|
|
||||||
sv->addChild(child1);
|
|
||||||
QLabel* child2 = new QLabel("CHILD", sv->viewport());
|
|
||||||
sv->addChild(child2);
|
|
||||||
QLabel* child3 = new QLabel("CHILD", sv->viewport());
|
|
||||||
sv->addChild(child3);
|
|
||||||
//! [3]
|
|
||||||
|
|
||||||
|
|
||||||
//! [4]
|
|
||||||
{
|
|
||||||
// Fill a 40000 by 50000 rectangle at (100000,150000)
|
|
||||||
|
|
||||||
// Calculate the coordinates...
|
|
||||||
int x1 = 100000, y1 = 150000;
|
|
||||||
int x2 = x1+40000-1, y2 = y1+50000-1;
|
|
||||||
|
|
||||||
// Clip the coordinates so X/Windows will not have problems...
|
|
||||||
if (x1 < clipx) x1=clipx;
|
|
||||||
if (y1 < clipy) y1=clipy;
|
|
||||||
if (x2 > clipx+clipw-1) x2=clipx+clipw-1;
|
|
||||||
if (y2 > clipy+cliph-1) y2=clipy+cliph-1;
|
|
||||||
|
|
||||||
// Paint using the small coordinates...
|
|
||||||
if (x2 >= x1 && y2 >= y1)
|
|
||||||
p->fillRect(x1, y1, x2-x1+1, y2-y1+1, red);
|
|
||||||
}
|
|
||||||
//! [4]
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
//! [0]
|
|
||||||
(void)Q3WhatsThis::whatsThisButton( my_help_tool_bar );
|
|
||||||
//! [0]
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue