invalid property name "style"?

在使用QMLButtonStyle时遇到style属性报错问题。通过调整使用的QtQuick.Controls版本为1.x系列,成功解决了该问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题:invalid property name “style”?

问题描述:

在学习QML ButtonStyle时,遇到style一直标红,使用qmlscene进行运行时,一直运行不过去,附上代码:

import QtQuick 2.0
import QtQuick.Controls 2.0
import QtQuick.Controls.Styles 1.4
Rectangle
{
    width: 320;
    height: 240;
    color: "gray";

    Button
    {
        text: "退出";
        anchors.centerIn: parent;
        style: ButtonStyle
        {
            background: Rectangle
            {
                implicitWidth: 70;
                implicitHeight: 25;
                border.width: Control.pressed ? 2 : 1;
                border.color: (Control.hovered || Control.pressed) ? "green" : "#888888";
            }
        }
        onClicked:
        {
           Qt.quit();
        }
    }
}

问题截图:

问题截图

问题解决:

这里写图片描述

这个问题是由于我导入最新的QtQuick.Controls 2.0的模块,导致与QtQuick.Controls.Styles 1.4版本有点不兼容,因此,我的解决方法是:使用QtQuick.Controls 1.x版本,问题就解决了。

如果小伙伴还有更好的解决方法,及时讨论哦!!!
请把下面mt5的指标改为mt4定义指标 #property indicator_chart_window #property indicator_buffers 5 #property indicator_plots 1 //--- main line #property indicator_type1 DRAW_COLOR_LINE #property indicator_color1 clrBlue, clrRed #property indicator_style1 STYLE_SOLID #property indicator_width1 2 #property indicator_label1 "SDL" //--- include #include <MovingAverages.mqh> //---- input parameters input ushort InpMAPeriod=80; // Period input ENUM_MA_METHOD InpMAMethod = MODE_LWMA; // Method input ENUM_APPLIED_PRICE InpAppliedPrice = PRICE_CLOSE; // Apply to input short InpShift = 0; // Shift input bool InpAlert = true; // Alert input bool InpNotification = true; // Notification input bool InpSound = true; // Sound //---- buffers double MABuffer[]; double MAColorBuffer[]; double vect[]; double wma1[]; double wma2[]; //--- global vars int ma1_handle; int ma2_handle; int new_period; int new_period_sqrt; datetime time_alert; int w; string ind_name; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- periods new_period_sqrt=(int)fmax(MathSqrt(InpMAPeriod),1); new_period=(int)fmax((InpMAPeriod/2),1); //--- handles ma1_handle=iMA(NULL,0,fmax(InpMAPeriod,2),0,InpMAMethod,InpAppliedPrice); ma2_handle=iMA(NULL,0,new_period,0,InpMAMethod,InpAppliedPrice); if(ma1_handle==INVALID_HANDLE || ma2_handle==INVALID_HANDLE) { Print("Error creating the indicator iMA"); return(-1); } //--- buffers SetIndexBuffer(0,MABuffer,INDICATOR_DATA); SetIndexBuffer(1,MAColorBuffer,INDICATOR_COLOR_INDEX); SetIndexBuffer(2,vect,INDICATOR_CALCULATIONS); SetIndexBuffer(3,wma1,INDICATOR_CAL
04-03
function varargout = myGui(varargin) % MYGUI MATLAB code for myGui.fig % MYGUI, by itself, creates a new MYGUI or raises the existing % singleton*. % % H = MYGUI returns the handle to a new MYGUI or the handle to % the existing singleton*. % % MYGUI('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in MYGUI.M with the given input arguments. % % MYGUI('Property','Value',...) creates a new MYGUI or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before myGui_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to myGui_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help myGui % Last Modified by GUIDE v2.5 05-Apr-2020 20:13:57 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @myGui_OpeningFcn, ... 'gui_OutputFcn', @myGui_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before myGui is made visible. function myGui_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUID
03-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值