Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.7k Posts
  • [SOLVED] QFileDialog

    3
    0 Votes
    3 Posts
    860 Views
    G
    Hi Thanks to both of you We will place something in our coding standards
  • 0 Votes
    5 Posts
    4k Views
    A
    Indeed: use a two-state checkbox and just show your dialog if the checkbox was toggled to unchecked. I'd also consider using a Qt::QueuedConnection between the toggle signal and the slot handling the confirmation. That will prevent a possible recursion in QCheckBox. The checkbox emits its signals as part of a handling the click on it. That means that at the moment you get the signal, and show your dialog, that code is triggered from within code inside QCheckBox that handles the state change. Now your handling code again changes the state, which means that you end up again inside the code section that triggered your confirmation code in the first place: a recursion. No idea if that is problematic in this case or not, but I'd not risk it and use a QueuedConnection. That way, you can be sure that QCheckBox is done completely handling one state change before getting into the next one.
  • ItemDelegate vs ProxyModel Subclass

    3
    0 Votes
    3 Posts
    860 Views
    A
    I'd advise against using the item views system for this. It seems you need complete widgets. The checkbox that is available via the CheckableProxyModel is rendered by the item view framework itself. It is not a real widget, it just uses the rendering code for one. I know, because I write the class. It doesn't do anything else than Qt models can all do by setting the right item roles and flags. Widgets in item views are generally not a good idea. Item views are simply not designed to do that. What you could do, is use Qt Quick for this instead. Quicks item views are designed to be able to contain everything you want, and Quick now supplies you with Quick Controls. That means that making a delegate that is just a mini-form is easy, and you can show one for every item in your model. Quick can also be embedded (again) in widget-based applications, so even if you have more widget-based code already, it may still be an option. Otherwise: go for your scroll-view based solution.
  • How to use QAbstractListModel with QTableView?

    3
    0 Votes
    3 Posts
    979 Views
    A
    I'd try QAbstractTableModel instead. It is easier to work with than a raw QAbstractItemModel if you don't need the nesting aspects (to build a tree, for instance).
  • [SOLVED] Customize QMdiArea QTabBar

    3
    0 Votes
    3 Posts
    2k Views
    A
    @void CustomizeMdiProxyStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget ) const { Q_CHECK_PTR( widget ); Q_CHECK_PTR( option ); if( !buttonParent.isNull() && widget && buttonParent.data()!= widget && element == QStyle::PE_IndicatorTabClose && option ) { const QTabBar* tabBar = qobject_cast<const QTabBar*>(widget); Q_CHECK_PTR( tabBar ); QStyleOption opt( *option ); opt.state &= ~( QStyle::State_Selected ); QProxyStyle::drawPrimitive ( element, &opt, painter, widget ); } else QProxyStyle::drawPrimitive(element, option, painter, widget); }@ Solution can be broken in case of current implementation change but has the desired visual effect and keeps current style. Thanks Andre for suggestion.
  • Passing singal to textfield

    13
    0 Votes
    13 Posts
    4k Views
    p3c0P
    @ anchors.fill: parent speed: xte mouseArea.onClicked: { ms.cppSlot(xte) //works //Qt.quit(); qmlSignal("yeah!!!") //works } @ What does not work here ?
  • [Solved] Mouse press and hold event for QWindow?

    4
    0 Votes
    4 Posts
    5k Views
    I
    I ended up using a QTimer. I basically used \Qt5.4.0\5.4\Src\qtdeclarative\src\plugins\qmltooling\qmldbg_qtquick2\inspecttool.cpp as a guide.
  • Can QPageSetupDialog "Format For:" printer be programmatically set?

    4
    0 Votes
    4 Posts
    1k Views
    F
    Did you ever resolve this? I am getting the same issue in 5.4.
  • Windows QT Deployment not working (VS2010 + QT 5.4.0)

    4
    0 Votes
    4 Posts
    3k Views
    Y
    @hskoglund i will give that a try tomorrow @SGaist the error message is somehow gone, i had it as an image, but it was something like "runtime error" without much informaiton. Furthermore i tested it both with Release and Debug.
  • I ran qtcreator as sudo and now project isn't working

    2
    0 Votes
    2 Posts
    1k Views
    SGaistS
    Hi, Because you called it with sudo, so you ran it with root privileges and thus everything Qt Creator did was with the corresponding rights (writing files etc.). Right now you should delete the build directory and your project.pro.user and open again Qt Creator. Important note: never ever do development as root, you can kill your OS without even noticing before it's way too late.
  • Downloading data from nseindia

    7
    0 Votes
    7 Posts
    2k Views
    R
    Eureka, Its working .... i have added the header fields with user-agent, host, accept-agent ..etc fileds Thanks to everyone.
  • Sheet dialog and Menu bar-focus issue

    4
    0 Votes
    4 Posts
    1k Views
    D
    QApplication::activeModalWidget(),solved the issue for me
  • [SOLVED ]color dialog currentColor offline seting

    5
    0 Votes
    5 Posts
    1k Views
    M
    i know about currentAlpha but .r .g .b :) same problem...when i change first color its ok second color change change also first color to currentColor
  • 0 Votes
    6 Posts
    7k Views
    L
    Thanks a lot ! omg, epick fail
  • Qt JSON access to elements value

    2
    0 Votes
    2 Posts
    917 Views
    A
    You don't need to go through QVariantMap, but API not all that fantastic either. See QJsonObject, QJsonValue, and QJsonArray for details. However, you're not bound to only use Qt itself of course. Any C++ library will do really. So, perhaps you could look into "this":https://github.com/nlohmann/json as it seems to support a syntax very much like what you use in PHP.
  • Change dock icon on OS X with Qt 5

    1
    0 Votes
    1 Posts
    506 Views
    No one has replied
  • Does Support?

    2
    0 Votes
    2 Posts
    469 Views
    SGaistS
    Hi, You need to update Qt Creator, since 5.2 at least Qt Creator 3
  • [Solved] Ignoring old commands - for moc files

    7
    0 Votes
    7 Posts
    5k Views
    A
    Useful. I wasn't aware of that operator. Thanks!
  • 0 Votes
    1 Posts
    511 Views
    No one has replied
  • How to set QComboxItem in a QStyledItemDelegate

    16
    1 Votes
    16 Posts
    6k Views
    D
    Well I got it to work for one item, but for two or more items the second item fails. I think the call to edit gets on the event loop and so things are not whre they ought to be. Here is what I have @// main loop where I want to set the data: for (int i=i=0;i<childCount;i++) { valueDestin = (FieldValueItem)destination.child(i,AvailableValueCol); QModelIndex mi = valueDestin->index(); if ((i == 2) || (i == 3)) { fieldValueDelegate->setSilent(true,1); // set index to item availableFieldsTree->edit(mi); // qApp->processEvents(QEventLoop::WaitForMoreEvents,500); //availableFieldsTree->closePersistentEditor(mi); //qApp->processEvents(QEventLoop::WaitForMoreEvents,500); fieldValueDelegate->setSilent(false,-1); } .... void FieldValueDelegate::setSilent(bool on, int ci) { isSilent = on; comboIndex = ci; if (!isSilent) editCB = 0; } void FieldValueDelegate::setEditorData(QWidget * editor, const QModelIndex & index) const { qDebug() << "Set Editor Data" << FILE << LINE; QComboBox *cb = qobject_cast <QComboBox *> (editor); if (cb && isSilent) { cb->setCurrentIndex(comboIndex); } QStyledItemDelegate::setEditorData(editor,index); } @ If I just have i set to 2, or i set to 3 (that is one index) in the loop above the index will get set, and I will see the result in my treeview, but when I try to both indexes in it fails on the second pass . There is an error message from Qt on the second iiteration: editing failed I guess Qt was not made to do this kind of stuff. If you know a quick fix please let me know, otherwise I will just give this thread a rest. Thanks to all that tried to help