Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.8k Posts
  • 0 Votes
    6 Posts
    2k Views
    V
    Jothi - suggest you to edit the subject with [SOLVED] as the issue is solved.
  • 0 Votes
    9 Posts
    3k Views
    V
    When you create a child class in a parent class and try to delete the child class in the class itself, you will most definitely get a segfault. It is the parents job to mop that up.
  • QDockWidget dock resize event order

    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • Showing 3D models from different camera angles

    1
    0 Votes
    1 Posts
    2k Views
    No one has replied
  • Using GPS in Qt applications

    2
    0 Votes
    2 Posts
    2k Views
    L
    You have to use QGeoPositionInfoSource and SatellitePositioningMethods. Last year I published a simple wiki article which shows how to "retrieve location using Qt mobility":http://qt-project.org/wiki/Retrieve_Location_Using_Qt_Mobility
  • Cant save in register

    13
    0 Votes
    13 Posts
    6k Views
    R
    [quote author="Andre" date="1334744554"]Please stop replying to yourself. If you're the last poster, and you have something to add, please just edit your previous message instead. There is an edit link next to each of your postings. [/quote] Ok, sorry for many messages. AcerExtensa i was wrong, your code was worked, but only with HKEY_CURRENT_USER, not MACHINE. I dont make code to write in HKEY_LOCAL_MACHINE despite the fact that i am admin on my computer. Thank you all for your help!
  • Designing node editor widgets

    3
    0 Votes
    3 Posts
    6k Views
    S
    It's not a reply to your questions but maybe you will find it useful : http://algoholic.eu/qnodeseditor-qt-nodesports-based-data-processing-flow-editor/
  • Cannot find -lQAxContainerd [SOLVED]

    4
    0 Votes
    4 Posts
    2k Views
    A
    Please add [SOLVED] to the topic subject...
  • QSortFilterProxyModel: inconsistent changes reported by source model

    17
    0 Votes
    17 Posts
    13k Views
    G
    As ZapB said [quote author="ZapB" date="1310123242"]Setting a proxy is a one-liner[/quote]unless you must overwrite a standard function of QSortFilterProxyModel. Normally removing rows will be done in the sourcemodel. As you do a selection in the view you have to map the indexes getting from the view to the source with @// single selection QModelIndex SourceIndex = tableProxyModel->mapToSource(viewIndex); // multiple selection QModelIndexList SourceIndexList; for (int i=0; i<viewIndexList.length(); i++) { SourceIndexList.append(tableProxyModel->mapToSource(viewIndexList[i])); } @ Also, if you have multiple selection you must sort the indexlist before removing like this: @void CatalogTableModel::removeSelectedRows(const QModelIndexList &indexlist) { QList<int> rows; foreach(const QModelIndex & index, indexlist) { rows.append(index.row()); } qSort(rows); int prev = -1; for(int i=rows.count()-1; i>=0; i-=1 ) { int current = rows[i]; if(current != prev) { QModelIndex _index = createIndex(current, 0); removeLabel(_index); prev = current; } } } @ Cheers, Thomas Edit: Uuups, little bit late ...
  • Displaying Unicode Characters

    2
    0 Votes
    2 Posts
    2k Views
    S
    AFAIK, the "Rectangle"s are displayed when you're missing a font in you're system. "Question Mark"s are displayed when you have a problem with encoding.
  • °C displayed as °C

    11
    0 Votes
    11 Posts
    6k Views
    A
    should look like this: @ this->setLblText2(trUtf8("°C")); void MLineEdit::setLblText2(QString s ) { label2->setText(s); } @
  • How to cancel pending(unprocessed) emitted signals

    5
    0 Votes
    5 Posts
    13k Views
    A
    Yeah, that should work as well, but only for the main eventloop. It is not a general solution for getting rid of signal-related event queues between threads. Note that the eventType is an int, by the way.
  • [solved] Changing row background of tableview afterwards

    12
    0 Votes
    12 Posts
    10k Views
    G
    Hi, after many unsuccessful tests with Qt::BackgroundRole and setData() I've switched to the delegate option. And, if I had knew how easy it is to use this possibility I had saved 3 days of frustration ... For any newbies who want to know how this works, here's my implementation: First, I delete all stuff with setData ... Second, I've overwritten the paint() function of QStyledItemDelegate: @void BackgroundColorDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { if(index.data().isValid()) { QStyleOptionViewItem viewOption(option); painter->save(); painter->fillRect(option.rect, QColor(238, 233, 233, 255)); painter->restore(); viewOption.palette.setColor(QPalette::Text, QColor(Qt::black)); QStyledItemDelegate::paint(painter, viewOption,index); } else { QStyledItemDelegate::paint(painter, option, index); } } @ (found it here: "QTableView and QTreeView item background":http://permalink.gmane.org/gmane.comp.lib.qt.general/29846 and here: "Change appearence of selected row in QTableView":http://www.qtcentre.org/threads/21482-Change-appearence-of-selected-row-in-QTableView ) Third, I create the delegate object: @BackgroundColorDelegate* m_background_delegate;@ @m_background_delegate = new BackgroundColorDelegate;@ Fourth, I activate the custom delegate every time I need it (normally in the view mode) else the default delegate will use: @void VdBmtcLearn::changeBgOfSelectedLabelsInView(bool bg_change) { QList<int> indexes_of_labels = m_controller->getIndexesOfFrameLabels(m_actual_frame.viewed_labels_list); for (int i=0; i<indexes_of_labels.length(); i++) { QModelIndex sourceIndex = m_model->index(indexes_of_labels[i], 0); QModelIndex viewIndex = getViewIndex(sourceIndex); if (bg_change) m_view->m_table->setItemDelegateForRow(viewIndex.row(), m_view->m_background_delegate); else m_view->m_table->setItemDelegateForRow(viewIndex.row(), new QStyledItemDelegate); } } @ (found how to call the custom delegate here: "Show other data in QTableView with QItemDelegate":http://stackoverflow.com/questions/2013052/show-other-data-in-qtableview-with-qitemdelegate ) Thanks all for helping anyway ;-) Cheers, Thomas
  • [SOLVED =)]ComboBox Qstring but need an int or GLenumb

    12
    0 Votes
    12 Posts
    6k Views
    A
    You are welcome! Please add "[SOLVED]" to the topic subject.
  • Call a function at a dialog execution

    3
    0 Votes
    3 Posts
    6k Views
    N
    Hi Daniel, Thank you for your reply. I have tested your 'untested' :D solution. Unfortunately, it is not what I need. Remember that my functionToBeCalled() is a function that does some animation (inside a QGraphicsView), so if we call this function before the exec() function, the user will not see the animation. I have got an idea but could not make it work. In the following code, I re-implement completely the exec() function, by just copying the source code of QDialog::exec() and adding functionToBeCalled() after show(): @int Dlg::exec() { Q_D(QDialog); if (d->eventLoop) { qWarning("QDialog::exec: Recursive call detected"); return -1; } bool deleteOnClose = testAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose, false); d->resetModalitySetByOpen(); bool wasShowModal = testAttribute(Qt::WA_ShowModal); setAttribute(Qt::WA_ShowModal, true); setResult(0); //On Windows Mobile we create an empty menu to hide the current menu #ifdef Q_WS_WINCE_WM #ifndef QT_NO_MENUBAR QMenuBar *menuBar = 0; if (!findChild<QMenuBar *>()) menuBar = new QMenuBar(this); if (qt_wince_is_smartphone()) { QAction *doneAction = new QAction(tr("Done"), this); menuBar->setDefaultAction(doneAction); connect(doneAction, SIGNAL(triggered()), this, SLOT(_q_doneAction())); } #endif //QT_NO_MENUBAR #endif //Q_WS_WINCE_WM bool showSystemDialogFullScreen = false; #ifdef Q_OS_SYMBIAN if (qobject_cast<QFileDialog *>(this) || qobject_cast<QFontDialog *>(this) || qobject_cast<QWizard *>(this)) { showSystemDialogFullScreen = true; } #endif // Q_OS_SYMBIAN if (showSystemDialogFullScreen) { setWindowFlags(windowFlags() | Qt::WindowSoftkeysVisibleHint); setWindowState(Qt::WindowFullScreen); } show(); /****** MY ANIMATION HERE *******/ functionToBeCalled(); #ifdef Q_WS_MAC d->mac_nativeDialogModalHelp(); #endif QEventLoop eventLoop; d->eventLoop = &eventLoop; QPointer<QDialog> guard = this; (void) eventLoop.exec&#40;QEventLoop::DialogExec&#41;; if (guard.isNull()) return QDialog::Rejected; d->eventLoop = 0; setAttribute(Qt::WA_ShowModal, wasShowModal); int res = result(); if (deleteOnClose) delete this; #ifdef Q_WS_WINCE_WM #ifndef QT_NO_MENUBAR else if (menuBar) delete menuBar; #endif //QT_NO_MENUBAR #endif //Q_WS_WINCE_WM return res; }@ The first error I got is 'QDialog::d_func' : cannot access private member declared in class 'QDialog'. Hope somebody can help. Have a nice day !
  • Using QVariantMap with dbus

    1
    0 Votes
    1 Posts
    4k Views
    No one has replied
  • HOWTO get a ComboBox in a TableView to activate on a single click?

    6
    0 Votes
    6 Posts
    8k Views
    S
    You are welcome!!!!
  • [Solved] Grab frames from video

    6
    0 Votes
    6 Posts
    5k Views
    V
    Thanks for the information Ashika Umanga!
  • 0 Votes
    3 Posts
    7k Views
    A
    My case: dataChanged when nothing added/removed, otherwise - resetModel By now I implemented a good enough simplified version of what I wanted. I figured that since 5% of changes max are going to be addition/removal (maybe even less than 1% will be seen by user). So I just compare sorted source and target lists, if the contact do differ, model is reset, otherwise only dataChanged is signal. In general: still intelligent list/listmodel comparison should be useful Andre, your proposal seems to rely on the assumption that external source of changes (messenger transport API) is reliable and that my code also doesn't go to unexpected states (imagine double addition if by mistake same signal is connected twice). In my case I don't trust external API much (I prefer refetching everything unless it effects performance) and wouldn't mind extra protection against my own mistakes as well. Your proposal probably makes a lot of sense when performance is critical (dozens on thousands of elements), yet for a contact list with a few items I'd really prefer less intelligence and a simple utility: pass it old and new list and it will figure the diff. Sort of like "git add/commit" calculate the diff for the whole file(s) instead of changing/committing each line separately. Anyway that is probably too much of a theory for now. I just thought that such a list comparison is quite a common task and I was wondering if there's already a "diff calculator" that can do it.
  • 0 Votes
    6 Posts
    7k Views
    A
    Listening to any file is not a problem as long as you know the name of a file to watch. If I understand it correctly by default QSettings can fetch values from up to 4 different sources. E.g. from QSettings docs: @ On Mac OS X versions 10.2 and 10.3, these files are used by default: $HOME/Library/Preferences/com.MySoft.Star Runner.plist $HOME/Library/Preferences/com.MySoft.plist /Library/Preferences/com.MySoft.Star Runner.plist /Library/Preferences/com.MySoft.plist @ Only the first of the above file names is reported by QSettings::fileName(). If you want to listen to changes coming from the other ones you just have to know the file names. That is, of course, error-prone and not very cross-platform. It's not an issue in my particular case (we use one file only), yet in general it would be cool to be able to watch for settings changes originating from any of the supported sources.