I’m using a QTabWidget to display various data. This data is contained in classes that are derived from QWidget. As I have several versions of the same data ( for several different years ), I want to be able to swap the displayed version. I use a QComboBox to call a method that does that for me. On construction, I create my data and put one of the widgets into my tabWidget:
// during construction
MyData *firstData, *secondData; // MyData is a custom class, derived from another virtual custom class that derives from QWidget
firstData = new MyData();
secondData = new MyData();
// do some parameterisation
// ...
_allData->append(firstData); // _allData is a QList that stores all different versions of my data
_allData->append(secondData);
_ui->dataLayout->addWidget( _allData->at(_allData->count() -2)); // dataLayout is the layout of one of the tabs of my tabWidget. This complicated way of adding the correct widget has it's background. I know I could simply append firstData, but I need to be flexible if I want to have more versions of my data.
So far so good. This works without a problem for all different tabs I use.
I then have a comboBox that calls a slot named ‘changeYear’ on the signal ‘currentIndexChanged(QString)’. This slot looks like this:
void MyClass:changeYear(QString year) {
int displayYear = year.toInt()
_ui->dataLayout->takeAt(0); // I would expect this to remove the QLayoutItem that encapsulates my Data from the Layout.
//_ui->dataLayout->update(); this doesn't work either - makes no difference.
// add the correct widget
for ( int i = 0; i < _allData->count(); ++i ) {
if ( _allData->at(i)->year() == displayYear ) { // Data->year() returns an int I use to identify which version of my Data this is
_ui->dataLayout->addWidget(_allData->at(i));
break;
}
}
}
The slot gets called correctly and the for-loop correctly identifies the new data I want to add to my layout. However, takeAt() doesn’t remove the old widget. This leads to having both Widgets in my layout at once, which, of course, doesn’t quite work.
I know I can do:
QLayoutItem *thisItem = _ui->dataLayout->takeAt(0);
delete thisItem->widget();
to get rid of it. That, however, doesn’t help me, as I don’t want to destroy my data. This is not up for discussion.
However, whatever I tried to only remove the Widget from my layout, it didn’t work. I could simply add all my Data Widgets to my layout and hide() and show() accordingly, but this causes extra headache for all my signals and slots I’d have to take care of. Also, why would I want to do that in the first place?
Any chance I can just remove my Widget from the layout without having to destroy it?
↧
Removing widgets from layout without destroying them
↧
Problem with DB connection
I’ve been trying to connect my program to a database, unsuccessful
#include <QCoreApplication>
#include <QtSql>
#include <QtDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
// QString servername = "LOCALHOST\\SQLEXPRESS";
QString servername = "LOCALHOST\\MYSQL";
QString dbname = "test.dat";
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setConnectOptions();
QString dsn = QString("DRIVER=(SQL Native Client);SERVER=%1;DATABASE=%2;UID=root;PWD=root;").arg(servername).arg(dbname);
// QString dsn = QString("DRIVER=(SQL Native Client);SERVER=%1;DATABASE=%2;Trusted_Connection=Yes;").arg(servername).arg(dbname);
// db.setDatabaseName(":memory:");
db.setDatabaseName(dsn);
if(db.open())
{
qDebug() << "Opened!";
db.close();
} else {
qDebug() << "Error: " << db.lastError().text() ;
}
return a.exec();
}
The error I keep getting is “out of memory Error opening database”.
I use UniServer, with Apache and MySQL.
If anyone has any ideas, I’d be grateful.
Regards!
↧
↧
Problem with DB connection
I’ve been trying to connect my program to a database, unsuccessful
#include <QCoreApplication>
#include <QtSql>
#include <QtDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
// QString servername = "LOCALHOST\\SQLEXPRESS";
QString servername = "LOCALHOST\\MYSQL";
QString dbname = "test.dat";
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setConnectOptions();
QString dsn = QString("DRIVER=(SQL Native Client);SERVER=%1;DATABASE=%2;UID=root;PWD=root;").arg(servername).arg(dbname);
// QString dsn = QString("DRIVER=(SQL Native Client);SERVER=%1;DATABASE=%2;Trusted_Connection=Yes;").arg(servername).arg(dbname);
// db.setDatabaseName(":memory:");
db.setDatabaseName(dsn);
if(db.open())
{
qDebug() << "Opened!";
db.close();
} else {
qDebug() << "Error: " << db.lastError().text() ;
}
return a.exec();
}
The error I keep getting is “out of memory Error opening database”.
I use UniServer, with Apache and MySQL.
If anyone has any ideas, I’d be grateful.
Regards!
Edit: Answer found! [ https://qt-project.org/forums/viewthread/26150/#119424 ]
↧
QTableView strange behavior after editing
After finishing edit any new row then pressing ENTER QTableView hides the data from the new row and shows “!” character in Vertical header of that row although it added physically in the database table!!
tableModel->insertRow(tableModel->rowCount());
how can I fix this issue?!
↧
QML ShaderEffect and property type
Hi all,
I would like to pass a matrix3×3 to my openGL script but I can’t find the right type to use in QML.
It works with a matrix4×4 in the following example :
ShaderEffect {
...
property matrix4x4 uMatrix: Qt.matrix4x4(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1)
...
}
Unfortunately the QML type “matrix3×3” does not exist. I tried many other types without success.
Does anyone have a solution please ?
↧
↧
Help! Building Qt libraries for VS2012 runtime
Hi,
I need to build and link the latest (5.0.1) Qt libraries against the VS2012 runtime libraries.
I’m using the non-commercial Qt.
I’ve downloaded the qt-everywhere-opensource-src-5.0.1 package and now I’m stuck on some problems:
Apparently there is no proper cookbook on how to configure and build for vs2012 compatibility.
The current problem:
c:\qt5.0.1\qt-everywhere-opensource-src-5.0.1\qtbase\src\network\ssl\qsslsocket_openssl_p.h(66) : fatal error C1083: Cannot open include file: 'openssl/asn1.h': No such file or directory
My configure command line is:
configure –I C:\OpenSSL-Win32\include –I C:\OpenSSL-Win32 –I C:\OpenSSL-Win32\include\openssl -opensource -openssl-linked -debug-and-release -platform win32-msvc2012 –no-icu -nomake examples -nomake tests
(of course, the path to openssl is correct).
I couldn’t find the include path mentioned in the created Makefile.
Also tried to clean the configuration using ‘nmake confclean’ (suggested by ‘Configure’), but there is no such file ‘confclean’.
Any help?
↧
Qt 5 & Python integration
Hello,
I have a general question.
I have a couple of Python scripts (use python 2.6) based on Numpy, Scipy, PyLab, PyUsb, PySide, …
The goal is to integrated the python into Qt 5.0, build a nice GUI, write some extra C++ around it, compile to an exe so it can run as a stand-alone program for windows 7.
Finally, the user may not get access to the python code or any other code written in Qt or C++.
My question is this possible.
If yes, can you give nice starting points, examples, that explains how I can start and to do this integration.
Regards,
JrV
↧
[SOLVED] mingw32-make: *** No rule to make target 'all'
I have installed Qt 5.0.1 libraries and Qt Creator 2.6.2 for windows 32-bit (MinGW 4.7), and i get thew followind compile output:
14:18:25: Running steps for project QtGrid...
14:18:25: Starting: "C:\Qt\Qt5.0.1\Tools\MinGW\bin\mingw32-make.exe" all
mingw32-make: *** No rule to make target 'all'. Stop.
14:18:26: The process "C:\Qt\Qt5.0.1\Tools\MinGW\bin\mingw32-make.exe" exited with code 2.
Error while building/deploying project QtGrid (kit: Desktop Qt 5.0.1 MinGW 32bit)
When executing step 'Make'
What’s the problem exactly?
Thanks!
↧
QCA Build on QT5
Hi,
I’m trying to compile QCA to use it on QT5.
That’s why I downloaded the sources of QCA using the following link: http://delta.affinix.com/download/qca/2.0/qca-2.0.3.tar.bz2
I then downloaded the following patch and applied it using git: https://github.com/psi-plus/main/blob/master/patches/dev/qca_qt5.patch
C:\qca-2.0.3>patch -p0 < qca_qt5.patch
patching file `examples/cmssigner/certitem.cpp'
patching file `examples/cmssigner/cmssigner.pro'
patching file `examples/cmssigner/keyselectdlg.cpp'
patching file `examples/cmssigner/main.cpp'
patching file `examples/cmssigner/pkcs11configdlg/pkcs11configdlg.cpp'
patching file `examples/cmssigner/prompter.cpp'
patching file `examples/hashtest/hashtest.cpp'
patching file `examples/randomtest/randomtest.cpp'
can't find file to patch at input line 120
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|Index: plugins/qca-wingss/qca-wingss.cpp
|===================================================================
|--- plugins/qca-wingss/qca-wingss.cpp (revision 1336453)
|+++ plugins/qca-wingss/qca-wingss.cpp (working copy)
--------------------------
File to patch:
Skip this patch? [y]
Skipping patch.
8 out of 8 hunks ignored
patching file `src/qca_keystore.cpp'
patching file `src/support/console.cpp'
patching file `src/support/qpipe.cpp'
patching file `src/support/synchronizer.cpp'
patching file `src/support/syncthread.cpp'
patching file `tools/qcatool/main.cpp'
patching file `unittest/certunittest/certunittest.cpp'
Hunk #1 succeeded at 128 (offset -1 lines).
Hunk #3 succeeded at 229 (offset -1 lines).
Hunk #5 succeeded at 469 (offset -1 lines).
Hunk #7 succeeded at 635 (offset -1 lines).
Hunk #8 succeeded at 734 (offset -39 lines).
Hunk #9 succeeded at 875 (offset -1 lines).
patching file `unittest/hashunittest/hashunittest.cpp'
patching file `unittest/keygenunittest/keygenunittest.cpp'
patching file `src/support/syncthread.cpp'
patching file `unittest/metatype/metatype.cpp'
I then downloaded QConf and did a clean and build in QT Creator: https://github.com/psi-plus/qconf/
I then copied configure.exe and QConf.exe to the QCA sources folder.
In the QCA folder, I issued the following: qconf qca.qc
However, I got an error:
C:\qca-2.0.3>qconf qca.qc
qconf: ./conf does not exist.
Please help me to compile QCA on QT5.
Even if I’m using Windows, please give me instructions that are “portable”, I mean that I want to use QCA on Windows, Mac and Linux.
Thank you
↧
↧
How to pass a signal forwarded parameter into a lambda, defined in the connect statement?
I am having difficulties figuring out how to get access to a parameter, passed by a signal in the lambda the signal is connected to. Any ideas?
↧
QThread and QTimer
Hi,
I have a slot that is connected to QTimer’s signal. I like to move this function to another thread since it’s a very time consuming process but I also need to start or stop the function from running in runtime so I have to call timer->start() or timer->stop(). so far I’ve done this:
m_frameTimer = new QTimer(0);
m_frameTimer->setInterval(0);
connect(m_frameTimer, SIGNAL(timeout()), this, SLOT(timerFired()));
m_thread = new QThread(this);
m_frameTimer->moveToThread(m_thread);
and I call the m_thread->start() when a specific button is clicked and then I call timer->start() if the process is ready otherwise timer->stop. but it doesn’t work and it gives me the following error:
“QObject::startTimer: QTimer can only be used with threads started with QThread”.
↧
When will Qt5.0.2 be released as tar-ball?
Hi Guys,
does any one know when the 5.0.2 version will be released?
Will it be officially released?
I know I can get it from git but it would be nice to know if and when it will be officially released.
Best regards
Juergen
↧
Looking for Qt and C++ Developer in Sophia Antipolis (France)
Hi,
On behalf of our company I’d like to encourage you to apply for the offer below.
Cyclad is an international IT Consulting and Outsourcing Company. Since 2007 we have been supporting our Clients and Partners on European market in leading divers IT/ ITC projects. Our mission is to provide the highest quality services, while being concerned for personal development and job satisfaction of our Consultants.
Currently, for our client – a world leader in integration of communications solutions for multinational corporations, we are looking for candidates for the position of C++ Developer.
For more details please refer to our site:
http://www.infopraca.pl/employer/joboffer/view/id/8467402
If you are interested in this offer, please send us your application on rekrutacja@cyclad.pl
Best regards,
Jaroslaw Sitek
Cyclad
↧
↧
Animate QGraphicsWidget by change of position.
This must be an easy one, but for some reason I can’t animate my Widget.
So a snippet of my widget code is:
class RoundedBox : public QGraphicsWidget
{
Q_PROPERTY( QPointF pos READ pos WRITE setPos )
public:
RoundedBox(QGraphicsWidget *parent = 0);
QPointF pos() const{ return QGraphicsObject::pos(); } // don't really need these - just for debug
void setPos( QPointF& pos ) { QGraphicsObject::setPos( pos ); }
...
};
And in my main window
I have:
void MainWindow::animate()
{
QPropertyAnimation animation(_rounded_box, "pos"); // just change position
animation.setDuration(10000);
animation.setStartValue(QPointF(0, 0));
animation.setEndValue(QPointF(100, 30));
animation.start();
}
Now the RoundedBox widget has been added to the scene, and is visible, but does not move when ‘animate’ is called.
Am I doing something rather silly here???
↧
Qt performance on Windows CE
Hello,
I’ve been trying to find information on how Qt libraries performance compare to WinGDI on Windows CE 5. So far, I’ve found nothing useful.
Has anyone tried both? How does Qt perform?
I’m looking into Qt to develop on industrial embedded systems. And those systems have very limited resources. Ideally, I’d like to use Qt. But then, if the overhead is too high, I’ll have to go with the default WinGDI.
Thank you in advance,
JosepL
↧
MinGW Qt Application Deployment NOT WORKING
Before anything: yes, I have followed the guide: http://qt-project.org/doc/qt-5.0/qtdoc/deployment-windows.html
My platform target is windows.
My toolchain is mingw.
I am using Qt Creator.
Here are the versions:
Symptoms:
When I try deploying the application in its own folder with all the necessary DLL files, it seems to work on my dev machine. HOWEVER: on other machines I get these dialogs following a crash:
What is weird to me is that on my dev machine, when I rename the Qt installation folder, “C:\Qt\”, to “C:\Qt2\” or something, I get the same crash on my dev machine as well. Is there some strange dependency to the Qt installation folder that I have to modify or something that I don’t know about? :(
Oh yeah, here’s what my .pro file looks like:
#-------------------------------------------------
#
# Project created by QtCreator 2013-02-19T19:51:30
#
#-------------------------------------------------
QT += core gui network xml
greaterThan(QT_MAJOR_VERSION, 4): QT += multimedia widgets multimediawidgets
TARGET = MultimediaCaptionEditor
TEMPLATE = app
SOURCES += ...
HEADERS += ...
[edit, Picture links updated, koahnig]
↧
pause functionality in Qt using QTimer on button press
0 down vote favorite
I am trying to implement pause button for a game I am developing in Qt + OpenGL.
I want to implement it using QTimer. Basically I am updating screen per 100ms. So in order to pause game, I will stop the timer on button press. and when button is again pressed i will start the timer again
Here is my pauseOrPlay SLOT:
void Window::pauseOrPlay()
{
GLWidget::modifyTimer = TRUE;
GLWidget::isPaused = !GLWidget::isPaused;
GLWidget timerUpdater;
timerUpdater.timerFunc();
}
and Here is my timerFunc()
GLvoid GLWidget::timerFunc()
{
static QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
if( GLWidget::isPaused)
timer->start(100);
else
timer->stop();
}
But I am not getting the functionality. I get paused screen on this particular code and upon trying few tweaks here and there, sometimes I get screen updating very fastly which pointed me to this but I was unable to find cure to my problem somehow
This maybe bit naive question about Qt, so may be I am missing something very basic. Any help or Pointers??
↧
↧
QSqlDatabase: QMYSQL driver not loaded. Why?
Hi
I compiled Qt 5.0.2 with MySQL support. Driver plugin is there but program can’t load it with a funny message:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3
What am I doing wrong ?
↧
Problem building quazip-Libary 0.5.1
I have problems building the quazip libary (version 0.5.1) on Windows 7 (32-bit) with Qt 5.0.1 32-Bit LGPL installed.
When i run in the Qt-Commandprompt:
qmake
mingw32-make
with the directory set to the folder in which I extracted Quazip (C:\Qt\quazip-0.5.1\quazip), I get the following output:
C:\Qt\quazip-0.5.1\quazip>mingw32-make
mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory 'C:/Qt/quazip-0.5.1/quazip'
g++ -Wl,-s -shared -mthreads -Wl,--out-implib,release\libquazip.a -o release\qua
zip.dll object_script.quazip.Release -LC:\Qt\Qt5\5.0.1\mingw47_32\lib -lQt5Core
./release\unzip.o:unzip.c:(.text+0x1008): undefined reference to `crc32'
./release\unzip.o:unzip.c:(.text+0x10aa): undefined reference to `inflate'
./release\unzip.o:unzip.c:(.text+0x10da): undefined reference to `crc32'
./release\unzip.o:unzip.c:(.text+0x1110): undefined reference to `crc32'
./release\unzip.o:unzip.c:(.text+0x1327): undefined reference to `inflateEnd'
./release\unzip.o:unzip.c:(.text+0x1727): undefined reference to `get_crc_table'
./release\unzip.o:unzip.c:(.text+0x186f): undefined reference to `inflateInit2_'
./release\zip.o:zip.c:(.text+0xac7): undefined reference to `crc32'
./release\zip.o:zip.c:(.text+0xb7c): undefined reference to `deflate'
./release\zip.o:zip.c:(.text+0xcdf): undefined reference to `deflate'
./release\zip.o:zip.c:(.text+0xef5): undefined reference to `deflateEnd'
./release\zip.o:zip.c:(.text+0x13a8): undefined reference to `get_crc_table'
./release\zip.o:zip.c:(.text+0x1af9): undefined reference to `deflateInit2_'
./release\quaadler32.o:quaadler32.cpp:(.text+0x2e): undefined reference to `adle
r32'
./release\quaadler32.o:quaadler32.cpp:(.text+0x61): undefined reference to `adle
r32'
./release\quaadler32.o:quaadler32.cpp:(.text+0xa1): undefined reference to `adle
r32'
./release\quaadler32.o:quaadler32.cpp:(.text+0xb1): undefined reference to `adle
r32'
c:/qt/qt5/tools/mingw/bin/../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64
-mingw32/bin/ld.exe: ./release\quaadler32.o: bad reloc address 0x0 in section `.
rdata$_ZTI13QuaChecksum32[__ZTI13QuaChecksum32]'
collect2.exe: error: ld returned 1 exit status
Makefile.Release:106: recipe for target 'release\quazip.dll' failed
mingw32-make[1]: *** [release\quazip.dll] Error 1
mingw32-make[1]: Leaving directory 'C:/Qt/quazip-0.5.1/quazip'
makefile:34: recipe for target 'release' failed
mingw32-make: *** [release] Error 2
But in my Zlib-Folder (C:\Qt\Qt5\5.0.1\Src\qtbase\src\3rdparty\zlib) are all this listed files installed.
As I tried to solve the problem, I have added into the quazip.pro and into the quazip.pri:
INCLUDEPATH += $$[QT_INSTALL_PREFIX]/src/3rdparty/zlib
, how it is suggested at http://stackoverflow.com/questions/4449467/how-to-compile-and-use-quazip-on-windows-do-i-need-to-separately-install-zlib
I can’t find anything more, what could help me…
I hope someone of you can help me.
Greetings, LVreg
↧
Qt5 (How to install an addon/ module like Qt Location for instance)
Hello dear all!
I installed QtSDk 5.0.1 under Ubuntu this evening and the maintanance tool provides “Remove all components” only.
I would like to add the add-on/ module Qt Location to my Qt5 installation.
—-
Tried to build/ install it from source (cloned from git://gitorious.org/qt/qtlocation.git). qtlocation seems to depend on qt-quick3d.
How do I have to proceed to build and install all (incl. docs, imports etc.) into the tree under $QTDIR?
Tried:
git clone git://gitorious.org/qt/qtlocation.git
cd qtlocation
sudo `which qmake`
sudo make sub-src-qmake_all
sudo make install
But I had no success.
Hope to find some help here!
Best regards from Hamburg
joomie
↧