Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.6k Posts
  • Undefined reference to QMYSQLDriver

    5
    0 Votes
    5 Posts
    4k Views
    G
    [quote author="Naraha" date="1325690941"]It works now, but it seems that I have to learn the basics first. @Volker, it was already a fake username and password but never the less thanks, [/quote] Good to know it works. For fake username/password you'd better use "xxxxx" or "user"/"pass" - this way it's obvious that you didn't paste some real world credentials by accident :-)
  • Reflection over class members?

    7
    0 Votes
    7 Posts
    4k Views
    G
    [quote author="medvedm" date="1325690312"] Not sure why Volker dropped the smart-questions bomb. This doesn't seem like an unreasonable question to me. RTTI doesn't do what I am asking for, and I don't think it would have to be added in base C++. [/quote] The bomb is in the signature, everyone gets it and once I purge it, it's out of every reply :-) you can have your own signature, it's in the "edito profile"/member/profile link. [quote author="medvedm" date="1325690312"] Qt is already pulling information out about classes I write via moc, so I suppose that is why I'm asking if it is difficult to pull out some more information and make it available to users.[/quote] It would work only with QObject based classes, not for plain old classes - and for that be restricted anyways. For accessing members (you mean member methods or member attributes here?) you have the slots (for methods) and the properties (for attributes). Nothing prevents you from declaring every method as a slot, and providing a property for every attribute. I agree that the latter is cumbersome and adds some boilerplate.
  • How to add a external library on Windows

    8
    0 Votes
    8 Posts
    3k Views
    G
    You will most probably need the .hpp files and the .lib files. Without the first, your compilation fails, without the latter the linking fails. Some hints and a complete example have been given, you're supposed to adapt them to your needs.
  • How to load data in column based on previous settings.

    3
    0 Votes
    3 Posts
    2k Views
    G
    I do it this way: @ #include <QHeaderView> // to store the state: QSettings s; s.setValue("TableViewState", ui->tableView->header()->saveState()); // to restore the state: QSettings s; QByteArray tvState = s.value("TableViewState").toByteArray(); if(!tvState.isEmpty()) ui->tableView->header()->restoreState(tvState); @
  • QListWidget drag&drop

    5
    0 Votes
    5 Posts
    5k Views
    S
    I solved this, here is my code: @ void ListBox::dragMoveEvent(QDragMoveEvent *e) { if (e->mimeData()->hasFormat("application/x-item") && e->source() != this) { e->setDropAction(Qt::MoveAction); e->accept(); } else e->ignore(); } void ListBox::dropEvent(QDropEvent *event) { if (event->mimeData()->hasFormat("application/x-item")) { event->accept(); event->setDropAction(Qt::MoveAction); QListWidgetItem *item = new QListWidgetItem; QString name = event->mimeData()->data("application/x-item"); item->setText(name); /if (provider->getColumnType(name) == "text") { item->setIcon(QIcon(":/images/iString")); } else { item->setIcon(QIcon(":/images/iInteger")); }/ addItem(item); } else event->ignore(); } void ListBox::startDrag(Qt::DropActions supportedActions) { QListWidgetItem *item = currentItem(); QMimeData *mimeData = new QMimeData; QByteArray ba; ba = item->text().toLatin1().data(); mimeData->setData("application/x-item", ba); QDrag *drag = new QDrag(this); drag->setMimeData(mimeData); if (drag->exec(Qt::MoveAction) == Qt::MoveAction) delete takeItem(row(item)); } void ListBox::dragEnterEvent(QDragEnterEvent *event) { if (event->mimeData()->hasFormat("application/x-item")) event->accept(); else event->ignore(); } Qt::DropAction ListBox::supportedDropActions() { return Qt::MoveAction; } @
  • Updating the Windows style preview in QtDesigner

    4
    0 Votes
    4 Posts
    2k Views
    A
    I just said so: no. The only thing you might try, is to get yourself a recent KDE version, and find a KDE style that looks a lot like windows. I believe (not: know) that there are KDE styles that look quite a bit like more recent Windows versions.
  • Merging two columns using QSqlTableModel/QTableView

    2
    0 Votes
    2 Posts
    3k Views
    A
    Create a proxy model that does that.
  • 0 Votes
    3 Posts
    3k Views
    A
    I would use proxy models for each of your views. If you are on Qt 4.8, use [[doc:QIdentityProxyModel]] as the base for such proxies, if you are on Qt 4.7 or lower, use [[doc:QSortFilterProxyModel]] instead. In the proxy model, you simply reimplement the headerData() method to return whatever you need.
  • [Solved] QSqlDatabase memory leak.

    6
    0 Votes
    6 Posts
    8k Views
    L
    [quote author="Davita" date="1325664572"]Thank you very much Lukas, I appreciate your help. I didn't know different instance of QSqlDatabase shared same resources internally. Now I call open just once and nothing leaks anymore :)[/quote] You're welcome. Docnote to QSqlDatabase added.
  • QGraphicsScene population SLOW on Windows but not any other platform?

    2
    0 Votes
    2 Posts
    2k Views
    A
    I have no definitive answer, but a few questions that might shed some light on the issue: Have you tried turning off the BSP tree altogether using setItemIndexMethod(QGraphicsScene::NoIndex)? Is the scene invisible at the time it is populated? Is the scene attached to the view at the time it is populated? Have you tried creating the items, but NOT adding them to the scene? (Question is: Is the constructor of the items slow, or the addItem call?) Does the "40000 chips" Qt example run slowly?
  • Qpushbutton draws OpenGL problem

    5
    0 Votes
    5 Posts
    3k Views
    P
    In my code I use std::vector and create a base object class that has a virtual Render() call. I then subclass this base class for meshes and primitives. You would then in the main part of your application create a vector to hold these items. std::vector<MyDrawClass*> m_objects; as the application needs to queue objects to be rendered, you would do something like: m_objects.push_back(new Rectangle()); // Rectangle is a sub-class of MyDrawClass Then when you are ready to draw them you would do something like: @ void RenderScene() { std::vector<MyDrawClass*>::iterator it; for(it = m_objects.begin() ; it != m_objects.end; ++it) (*it)->Render(); } @ And given this example where I'm calling new (I actually use a model library that manages creation/destruction of objects as well as instancing.) when you are done though. @myApp::~myApp { std::vector<MyDrawClass*>::iterator it; for(it = m_objects.begin() ; it != m_objects.end; ++it) delete *it; m_objects.clear(); }@
  • 0 Votes
    13 Posts
    5k Views
    P
    [quote author="Andre" date="1325659958"]Could you post your whole implementation of your paintEvent()?[/quote] this is my implementation of paintevent @ void checkbox::paintEvent (QPaintEvent *e) { QCheckBox::paintEvent (e); QPainter paint(this); paint.drawPixmap (QRect(0,0,10,10), pixmap, QRect(0,0,10,10)); } @ Here i am getting both the image and the default widget as output.
  • Scroll area not working...

    7
    0 Votes
    7 Posts
    7k Views
    A
    In designer also i got it done...by adding these two line...:) @ ui->scrollAreaWidgetContents->layout()->addWidget(checkbox); ui->scrollAreaWidgetContents->layout()->addWidget(lineEdit); @ Anyway thak u so much for ur help 'pi88el'....:)
  • Building on a static version of qt

    12
    0 Votes
    12 Posts
    6k Views
    R
    <Qt Root folder>\Desktop\Qt\4.7.3\mingw\bin Here you can find, The dlls you require. When you take debug version, for example , QtCored4.dll its about 31mb. But what exactly you need is QtCore4.dll and is about 2.5 mb. same case for other libraries. Anyway, you are building statically, and you must be building the debug version.
  • C support question

    2
    0 Votes
    2 Posts
    2k Views
    J
    I'm happy to answer the question like this. ;-) answer is No. be friend with Bjarne Stroustrup
  • Draging a ListWidget item's icon to a label?

    6
    0 Votes
    6 Posts
    3k Views
    M
    [quote author="broadpeak" date="1325619302"] The drag&drop logic is the following (something like similar to this): Drag site: @ QMimeData* prepareListWidgetItem( const QString& path ) { QImage pic(path); QMimeData *mimeData = new QMimeData; mimeData->setImageData( pic ); QList<QUrl> urls; QUrl imageUrl( path ); urls.append( imageUrl ); mimeData->setUrls( urls ); mimeData->setText( imageUrl.path() ); return mimeData; } void DragLabel::mousePressEvent(QMouseEvent event) { if (event->button() == Qt::LeftButton) { QMimeData data = prepareListWidgetItem(picPath); QDrag *drag = new QDrag(this); drag->setMimeData(data); if (pixmap()) drag->setPixmap(pixmap()-> scaled(100,100, Qt::KeepAspectRatio)); drag->start(); } } @ Drop site: @ DropLabel::DropLabel(QWidget *parent) : QLabel(parent) { setAcceptDrops(true); } void DropLabel::dragEnterEvent(QDragEnterEvent event) { if (event && event->mimeData()) { const QMimeData md = event->mimeData(); if (md->hasImage() || md->hasUrls() || md->hasText()) event->acceptProposedAction(); } } void DropLabel::dropEvent(QDropEvent *event) { QPixmap pix; if(event && event->mimeData()) { const QMimeData *data = event->mimeData(); if (data->hasImage()) pix = data->imageData().value<QPixmap>(); else if(data->hasUrls()) foreach(QUrl url, data->urls()) { QFileInfo info(url.toLocalFile()); if(info.exists() && info.isFile()) pix = QPixmap(url.toLocalFile()); if (pixmap() && !pixmap()->isNull()) break; } else if(data->hasText()) { QUrl url(data->text()); QFileInfo info(url.toLocalFile()); if(info.exists() && info.isFile()) pix = QPixmap(url.toLocalFile()); } } if (!pix.isNull()) { setPixmap(pix); resize(pix.size()); } } @[/quote] I thank you for your example, but i was merely looking for the logic and the code behind ACTING upon the actual event of having dragged a ListWidget item over a label. Rest i can do myself.
  • Work with bluetooth

    3
    0 Votes
    3 Posts
    2k Views
    F
    You can try the following if targeting for Windows which is in Qt C++: https://projects.forum.nokia.com/qbluetooth Mind that it's not the official QBluetooth from the Qt SDK. The only problem is that it doesn't support the Microsoft Bluetooth Stack but only Bluesoleil. So if you want to use it you need to have Bluesoleil installed (https://projects.forum.nokia.com/qbluetooth/wiki#Otherusefulinformation)
  • QTabWidget: QLabel sometimes paints what's on the last tab

    8
    0 Votes
    8 Posts
    4k Views
    C
    Oops, missing part of tabtest.cpp: @ void TabTest::update_test_label() { int i = rand() % 100 + 1; QString s = QString("%1").arg(i,3); testlabel->setText( s ); i = rand() % 100 + 1; s = QString("%1").arg(i,3); testlabel2->setText( s ); i = rand() % 100 + 1; s = QString("%1").arg(i,3); testlabel3->setText( s ); i = rand() % 100 + 1; s = QString("%1").arg(i,3); testlabel4->setText( s ); i = rand() % 100 + 1; s = QString("%1").arg(i,3); testlabel5->setText( s ); } @
  • Best way to implement Window menu

    4
    0 Votes
    4 Posts
    2k Views
    G
    Sorry, I have no clue, why this is not a slot. You might want to file a suggestion on the "public bugtracker":https://bugreports.qt.nokia.com/. So at least it will be reconsidered for the upcoming Qt 5 release later this year.
  • [SOLVED] "Can't start because QtGui4.dll is missing from your computer"

    6
    0 Votes
    6 Posts
    67k Views
    V
    The method you stated is working. I started working on another project but had to come back to this issue. I added my Qt library directory to the environment variable PATH. Works like a charm now. Thank you!